+-- api/
| +-- common/
+-- config/
+-- docs/
+-- events/
+-- lib/
+-- scripts/
+-- services/
+-- models/
+-- tests/
+-- workers/
+-- .editorconfig
+-- .env.sample
+-- .gitignore
+-- .npmrc
+-- CONTRIBUTION.md
+-- Dockerfile
+-- package.json
+-- README.md
Contains:
- Actions, scripts that interact with the services in services folder.
- Endpoints, exposing the service to other services.
- Handles the validations and assertions of the requests
This folder contains all the logic that is shared across multiple files in the parent folder (api). Here you also have middlewares like the express middleware that has access to the request and response objects.
This is where configurations are loaded, configurations could be loaded from the environment variables either in production or in development based on where the service has been spawned. configs are grouped into components which allows you to manouver when you require the use of a service for example the mongodb url and many more.
i.e.
The process.env files is in the config files when an app starts it enables you to test if all the variables are available if not it throws an error hence one can never deploy an app with missing variables.
All the docs for this service should be here.
All api docs can go in here
All webhook docs can go in here if you need one
This is where all the events handlers should be located.
Contains the wrappers to external libraries and utilities. These are the helpful functions that accelerate the workflow and are often offered as packages and can be installed with npm.
This contains all scripts that are run once, E.g. Migration scripts, indice creators, administrative scripts, local test utilites or any build configs.
This is where all the business logic code should be located, usually grouped into features.
Here we usually have utilities we will need for test. Most test are close to their individual files
Contains things that should probably run b4 actual test, lik
Utitlies for test
- test/fixtures/ This is a fixed state to allow the app to be tested, this enables you to also clean up the code.
This should contain the schemas ,it also contains all the details for the app to operate efficiently This could be basic data required when changing states , when tasks are completesd succesfully.
Should contain anything that needs to run outside of the main process E.g. cron jobs used to run scheduled tasks
These other files include:
-
These are are editor configurations, just to make development smooth and standard across the board.
-
Has the samples for environment variable.
A.env
file must be created based on the variables in the .env.sample file.
Note:.env
file should only be used in development. -
Outlines all the files and/or files that should be ignored by git commits.
-
This contains
npm
's global configurations. -
Your contribution is welcomed. You can submit a PR with the changes you think might be helpful in this express-api-starter detailing the changes and the reasons.
-
Contains docker related settings
-
Pm2 config to make it easy to setup all processes
-
Has all npm/yarn related stuff. Dependancies, run scripts E.t.c, this file will be created automatically when
npm init
oryarn init
is run during the initialization of the project. -
Explains stuff :)
These files are in the root folder relative to the service
Tests are highly encouraged. Idealy, tests should be localised within a folder, they should be as close to the code/file being tested as possible, Tests could be in a tests
folder where it makes sense, E.g. If the tests are many.
Also, custom folders can be added as subfolders of any of the listed folders where necessary.