An skeleton express app that allows you to use ES6 syntax. Generated by express-generator cli.
Before anything else, you must have node installed on your machine.
In root of project config
folder you can change envs as dev,prod,stag,test
Before run server you must config Postgresql server configuration info in config => development.json
:
database:{
"host": "localhost",
"user": "postgres",
"password": "123456",
"database": "NodeJsDb",
"port":"5432"
}
Request life cycle;
requestA fire +++>>> api/v1/defect
--> Validation by Joi libraries as middleware in routes config;
---> After pass by validation process handleing by Controller
----> All of exception handle in this layer to CustomExceptionHandler as middleware
(send a full friendly error detail to response)
-----> if there is not error
------> Request sent to PresentionLayer as Logic and Process all logic flow on request
-------> PresentionLayer for do all transaction use defectService, machineService and etc as services
--------> Services communicated with DomainLayer Or Data as Repositories like defectRepository, machineRepository
---------> All of Data Logic must be handle by repositories
----------> Repositories use DbManager to do transaction like CRUD on Database
Mapping Classes From DomainLayer (Data/Model) to PresentationLayer (View):
---> mapped DbModel (QueryResultModel) to ViewModel (ApiResponseModel)
Mapping Classes From PresentationLayer (View) to DomainLayer (Data/Model):
---> mapped ViewModel (ApiRequestModel) to DbModel (QueryParamModel)
Done!
Use SQL Create Queries in src/domain/data/example-db.sql
to create your Postgresql DB
Add "type":"module"
to package.json file and after stop Dev Server for build should remove it.
Then, run on your terminal npm run watch:dev
, the server will restart everytime you make a change in your code.
Or if you want without watching you can run on your terminal npm-run-all build server
Run on your terminal npm test-unit
.
Run on your terminal npm test-integration
.
Also, You can see coverage of test in coverage
folder of root project
For stuff like heroku deployment, aws elasticbeanstalk, run npm run start
All logs as Debug, Info, Error, Warning generate on Logs folder as file when project run
Defect.postman_collection.json
transpile
- convert es6 and beyond code to es5 to a folder nameddist-server
clean
- delete transpiled folderbuild
- clean and transpileserver
- start transpile code