This is a boilerplate for project wish to use nodeJS, Typescript, clean architecture. Its built on top of ExpressJS. Some common libraries are included in the project, please refer package.json
for more details.
The base structure look like this:
config → configurations
src → source code
└ data → data access layer, e.g. db models, data repositories
└ models → data structure of data layer (db, files)
└ repositories → communicator between data and domain layer
└ domain → domain layer, e.g. usecases, entities
└ entities → data structure that use within domain layer
└ usecases → business rules
└ lib → infrastructure layer, e.g. frameworks, db drivers, plugins
└ presentation → presentation layer, e.g. controllers, socket gateway
└ controllers → route handlers
test → test files
tools → the build tools, CICD tool that not related to the business
.dockerignore → docker ignore file
.eslintignore → eslint ignore file
.eslintrc.js → eslint configurations
.gitignore → git ignore file
.prettierrc → prettier configurations
Dockerfile → docker configurations
gulpfile.js → Gulp entry file
nodemon.json → nodemon configurations
package.json → project info and dependencies
README.md → repo info
tsconfig.json → typescript configurations
yarn.lock → yarn dependencies lockdown
folder naming convention
- folder_name
- no restriction on plural or singular, depend on use cases
- e.g. system_configs
file naming convention
- file_name.functional_area.file_ext
- no restriction on plural or singuler, depend on use cases
- e.g. user.repository.ts, user_repository.interface.ts
These extensions are recommended to have in order to standardize coding style:
- ESLint -- EcmaScript linter
- Prettier -- Code formatter
Assumptions:
you are running on VS Code on Windows
- for other development environment, if you face problems in installing the required tools, please refer official manual online, or approach repo maintainers for help.
- Clone this repository locally.
- Install
yarn
globally/locally in your machine, installation guide. - Install development dependencies with
yarn install # or just yarn
- Install Gulp cli globally in your machine, installation guide
- Make sure you can build the project with:
yarn build
- To run the application in watch mode:
yarn start:dev
- To run the application in production mode:
yarn start:prod
- You can explore more available commands in package.json
You are encouraged to work in containerized environment to prevent compatibility issue.
Please install docker in your local machine before proceed, to get started.
To build app into docker image (need help?):
docker build -t <username/my-service>
To list available images in your machine(need help?):
docker images
To run built image (need help?):
docker run -d <container_id>
To list running container (need help?)::
docker ps
For more details on how to use docker, please refer doc.
Recommended to follow committizen practices when committing changes. Please install git cz on your machine.