SOLID Singleton architecture with 3 layers / MCM / Monolitic
📦api-posts
┣ 📂src
┃ ┣ 📂middlewares
┃ ┃ ┣ 📜apikey.middleware.ts
┃ ┃ ┗ 📜authentication.middleware.ts
┃ ┣ 📂modules
┃ ┃ ┗ 📂v1
┃ ┃ ┃ ┣ 📂controllers
┃ ┃ ┃ ┃ ┣ 📜post.controller.ts
┃ ┃ ┃ ┃ ┗ 📜user.controller.ts
┃ ┃ ┃ ┣ 📂interfaces
┃ ┃ ┃ ┃ ┗ 📜request.interface.ts
┃ ┃ ┃ ┣ 📂middlewares
┃ ┃ ┃ ┃ ┣ 📜post.middleware.ts
┃ ┃ ┃ ┃ ┗ 📜user.middleware.ts
┃ ┃ ┃ ┣ 📂models
┃ ┃ ┃ ┃ ┣ 📜permissions.model.ts
┃ ┃ ┃ ┃ ┣ 📜post.model.ts
┃ ┃ ┃ ┃ ┗ 📜user.model.ts
┃ ┃ ┃ ┣ 📂routes
┃ ┃ ┃ ┃ ┣ 📜post.route.ts
┃ ┃ ┃ ┃ ┗ 📜user.route.ts
┃ ┃ ┃ ┣ 📂test
┃ ┃ ┃ ┃ ┣ 📜post.test.ts
┃ ┃ ┃ ┗ 📂validators
┃ ┃ ┃ ┃ ┗ 📜user.validator.ts
┃ ┣ 📂services
┃ ┃ ┣ 📜jwt.service.ts
┃ ┃ ┣ 📜response-handler.service.ts
┃ ┃ ┣ 📜sequelize.service.ts
┃ ┃ ┣ 📜validator.service.ts
┃ ┃ ┗ 📜winston.service.ts
┃ ┣ 📂utils
┃ ┃ ┗ 📜logger.util.ts
┃ ┗ 📜app.ts
┣ 📜.env
┣ 📜.gitignore
┣ 📜README.md
┣ 📜index.ts
┣ 📜nodemon.json
┣ 📜package-lock.json
┣ 📜package.json
┗ 📜tsconfig.json
NodeJS Version: 14.15.4
NPM Version: 6.14.10
MYSQL Version: 8.0.23
- Install NodeJS and MYSQL Server
- Set enviroment variables configuration
./.env
- Install dependencies
npm install
- Create Database
- Run
CREATE DATABASE IF NOT EXISTS posts;Script into MYSQL Server
- Run
- Run project
npm run dev(This command automatically CREATES the necessary TABLES into DATABASE) this mode is developer mode if you need to run in production mode please check section "Build and run in JavaScript"
- Run seed file Script into MYSQL Server
./seed.sql(This script inserts default data)
- You can do requests to API (check down user admin credentials)
- You can find the postman collection at
./API_POSTS.postman_collection.json - You can import the postman enviroment at
./POSTS-LOCAL.postman_environment.json - First do login -> /login (credentiales are down).
- You can find the postman collection at
username: admin
password: admin123
- Transform TypeScript to JavaScript with:
npm run buildthis will create a folder./distwith project in JavaScript - Run project in JavaScript with
npm start
Run unit test:
- start test: npm run test
- generate coverage report: npm run test-report
You can find the coverage report at ./coverage once generated
- This is a base structure project and continue in development.
- This effort took about 22 Hours.
- Unit Tests are in progress but someones are ready!.