Skip to content

M-Shrief/Adeeb_ExpressTS

Repository files navigation

REST API for "Adeeb أديب", using Express with TypeScript

Overview: It's concerned with Arabic literature. It assumes a business model that enables you to order a specific piece of literature to be printed with especial colors and font. Then it'll be delivered to the customer, with the ability for the customer to follow up the process. And for special customers, it provides them with the ability to make bulk orders fast and easy. And if they’re willing to signup, they can review all of their past orders.

  • Tech stack:

    • Full TypeScript
    • Nodejs & Express.js
    • Database:
      • MongoDB & Mongoose
      • Caching with Redis ValKey
    • Docker Containerization
  • characteristics:

    • Regression tests with Vitest.
    • CI using Github actions testing
    • JWT Authentication & Authorization
    • Centralized Error Handling
    • Data Validation with Yup and express-validator
    • Security best practices from OWASP
    • …and more

File Structure

  • ./github for Github actions.

  • ./src:

    • app.ts is the main file for app logic, initializing middlewares and routes, and connecting to our MongoDB.

    • index.ts is the server file to run the app.

    • db.ts is the config file for MongoDB.

    • redis.ts is the config file for redis.

    • ecosystem.example.config.js is a template to generate PM2 config file ecosystem.config.js for process management and ENVs.

    • ./config file to import all environment variables, and use a complex configuration structure if needed.

    • ./components file contain app's solutions by self contained components with

      • model file for our mongoose models, representing app's data, using (*.model.ts) naming convention for every module.

      • service file for communicating(read/write) to our database, and make operations on data if needed, then return the data for ./controllers, using (*.service.ts) naming convention for every module.

      • controller file for coordinating HTTP request & responses, and set needed cookies and headers, using (*.controller.ts) naming convention for every module.

      • route file for establishing endpoints and controllers to every modules. Beside validating requests, and jwt authentication. Using (*.route.ts) naming convention for every module.

      • schema file for validation data for post and update methods by Yup. Using (*.schema.ts) naming convention for every module.

    • ./interfaces file for types' declarations, using (*.interface.ts) naming convention for every module, beside __types__ for general types. Every interface has an Enum: ERROR_MSG for this interface error messages, and baseEntity for TypeORM.

    • ./middlewares file for containing reused middlewares, which are used across the app, using (*.middleware.ts) naming convention for every module.

    • ./utils file for containing reused functions and centralized error handling, which are used across the app.

    • ./tests/e2e for E2E tests

  • .env.example as example for ENVs.

  • tsconfig.json for TypeScript config

  • vitest.config.ts for Vitest config

  • Dockerfile, compose.yaml and .dockerignore for containerization

About

All in TypeScript project for "Adeeb أديب" using NodeJS/Express.JS as a Rest API, trying to use OOP design.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages