Simple app with clean achitecture metodolgy & solid principle. using nodejs for server, typescript for OOP implementation, and docker for container
- Framework Independent
- We are trying to implement a server using rest and graphql by using an isolated business process see detail rest and detail graphql
- Testable
- perform a test on each layer using jest
- UI Independent
- Database Independent
- External agency independence
This application by default uses Docker and Docker Compose, so make sure Docker and Docker Compose are installed on your system
Script | Description |
---|---|
start | start server in prod mode execute file after builder, make sure build first |
dev | start server with development mode |
build | build script from typescript |
watch | build script from typescript and start server with dev mode |
tests | run all tests with jest |
tests:co | run all tests and generate coverage |
dev:up | start docker for development |
dev:down | stop docker for development |
prod:up | start docker for production |
prod:down | stop docker for production |
localdb:up | start docker for database without docker-compose |
localdb:down | stop docker for database without docker-compose |
look in command.md
for used command
Encapsulate entity
, application
, and adapter
layer in folder core
, and framework & driver
layer in folder backend
Book
Get All Book
Get Book By ID
Add Book
Update Book
Delete Book
Add Account
Get Account By Email
Check Account By Email
Controller
GetAllBookConttroller
GetBookByIdController
AddBookController
UpdateBookController
DeleteBookController
SignupController
LoginController
Presentation
GetAllBookPresenter
GetBookByIdPresenter
AddBookPresenter
UpdateBookPresenter
DeleteBookPresenter
SignUpPresentation
LoginPresentation
Validation
- validation with
composite pattern
- validation with
class-validator
&class-transformer
Framework
Rest
- detail doc- using
express
andswagger
(for api docs)
- using
Graphql
- using
apollo server
andgraphql-modules
- using
Database
Mongodb
Redis
-
Singleton
ex: in connection database and event dispatcher
-
Factory
ex: in make controller in framework etc.
-
Abstract Factory
-
Builder
ex: in HttpBodyBuilder class
-
Adapter
ex: router, controller etc
-
Composite
ex: in validation etc
-
Template Method
ex: in presentasion
-
Proxy
ex: in validation controller, authentication, auth middleware
-
Mediator
ex: in logging
-
Observer
ex: in logging
-
Dependency Injection
ex: in many comunicated class
-
Reponsitory Pattern
ex: all transaction with database
- bcrypt - for hashing
- jsonwebtoken - for encrypting
- body-parser - parsing http body
- cors - handle cors request
- dotenv-extended - for configuration
- dotenv-parse-variables - for parsing configuration variable
- express - router framework
- module-alias - aliases module for simple access
- mongoose - mongodb object modeling
- morgan - log request
- morgan-body - log request body
- winston - custom system logger
- swagger-ui-express - api documentation
- class-validator & class-transformer - validate input request
- apollo-server-express - graphql server
- gprahpql-modules - toolling manage graphql
- typescript
- tsc-watch - run watch in detach mode
- nodemon
- mongodb-memory-server - use mongodb in memory
- tsconfig-paths - module aliases for typescript
- eslint, @typescript-eslint/parser, @typescript-eslint/eslint-plugin - linter
- prettier, eslint-config-prettier, eslint-plugin-prettier - formatter
- husky - git hook
- mongodb-memory-server - mongodb run in memory
- jest - unit testing
- ts-jest - jest for typescript
- faker - mockup helper
- bson-objectid - mock objectid
- supertest - request to server
- @types/bcrypt
- @types/jsonwebtoken
- @types/cors
- @types/dotenv-parse-variables
- @types/express
- @types/morgan
- @types/node
- @types/faker
- @types/validator
- @types/supertest
- @types/swagger-ui-express
Node Clean Architecture -Deep Dive
Backend API Server Development with Node.js from Scratch to Production