Stack:
- NodeJS
- Express
- TypeScript
- Nodemon
- Babel
- ESLint
- PostgreSQL
- Sequelize
- Winston
- Joi
- JsonWebToken
- Cors
To start project, please, clone the repo, type in the terminal npm install and then run command npm start.
In the root directory there are main config files of the project:
- tsconfig.json - config for TS compilier
- README.md - project's documentation
- .package.json - all the project's dependencies and commands
- .gitignore - git exceptions
- .eslint - code style config
- client - directory for client-side code (view part for browsers)
- server - directory for server-side code (endpoints, db connection and etc.)
- node_modules - nodeJS library
server directory contains following:
- app.ts - server root file where server starts
- /controllers - endpoints functionality
- /data-access - db intermediate
- /db - db connection
- /middlewares - app middle-wares which is using in the app.ts
- /models - db models
- /routes - all the project's endpoints here
- /services - one of the layer of 3-layer-architecture
- /types - server instances types
client directory contains following:
- src - client code
Endpoints created during this task:
- /users (with GET method returns array of dummy users)
- /users/:id (with GET method returns array of dummy user with param-id)
- /users (with POST method creates new user in the array of dummy users)
- /users/:id (with PUT method updates user in the array of dummy users)
- _/suggest/users?limit={number}&loginSubstring={string} (with GET method returns array of logins matched with input value)
Added db directory with PostgreSQL connection via Sequelize. Added data-access directory with methods to manipulates directly to db. Added 3-layer architecture (data-access/services/controllers).
Added new model UserGroup for through-table "user_groups".
Added Winston package for logging server errors. Added to every controller error log name, arguments which have been passed to the controller function, error message.
Added new packages cors and jsonwebtoken and middle-ware for authentication. Implemented authentication with JWT. Added new login endpoint and auth middleware.
Added unit tests for users controller and groups controller. Added services layer in order to establish 3-layer architecture on the server (data-access/services/controllers).