RafaelGSS / node-architeture-project-design

:bookmark_tabs: A Node.js service structure - Package CLI (napd)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NodeJS API Structure

The project structure for helping new api using any http server ( Using express for these boilerplate )

Install from CLI

HERE

Structure

bin/
config/
  routes/
/src/
|- data/
|-- connections/
|-- repositories/
|-- structures/    
|- domain/
|- handlers/
|- middlewares/
|- routes/
|- services/
|- utils/
/tests/

Concept of Structure

This structure, is based on some designs like DDD, Middleware Based NodeJS and the folders has the follow objectives:

bin/ - Binaries folder, can be used for routines postinstall of npm.

config/ - All of the configurations autoload of the project, like database variables.

config/routes/ - Autoload of routes for less dependency.

src/data/ - Contains the files for manipulating the connection ( repositories, structures, connection )

src/domain/ - Following the concept of DDD, the domain can be a domain of your application.

src/handlers/ - Following the concept of Middleware Based, the handlers manipulate the requests and delegate to your services.

src/middlewares/ - Middleware of routes, can be Auth, Roles...

src/routes/ - All routes for your project ( Obs: The route need has the name like *.route.js inside folder routes/ ).

src/services/ - Services for your application.

src/utils/ - Utils for your application, parser, and any util.

tests/ - Tests, actually using JEST.

Tests

npm install
npm test

Dependencies

  • dotenv: Loads environment variables from .env file
  • express: Fast, unopinionated, minimalist web framework
  • express-rescue: A wrapper for async functions which makes sure all async errors are passed to your errors handler
  • filter-files: Recursively read directories and return a list of files, filtered to have only the files for which the (optional) filter function returns true. Sync and async.
  • is-directory: Returns true if a filepath exists on the file system and it's directory.
  • lodash: Lodash modular utilities.
  • mongodb: The official MongoDB driver for Node.js

Dev Dependencies

  • @types/dotenv: TypeScript definitions for dotenv
  • @types/express: TypeScript definitions for Express
  • @types/node: TypeScript definitions for Node.js
  • chai: BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
  • mocha: simple, flexible, fun test framework
  • nodemon: Simple monitor script for use during development of a node.js app.
  • tslint: An extensible static analysis linter for the TypeScript language
  • typescript: TypeScript is a language for application scale JavaScript development

License

MIT

CONTRIBUITING

Please read CONTRIBUITING.md

TODO

Please read TODO

About

:bookmark_tabs: A Node.js service structure - Package CLI (napd)

License:MIT License


Languages

Language:JavaScript 84.6%Language:TypeScript 15.4%