Skip to content

Starter repo with basic signup and login along with JWT implementation

Notifications You must be signed in to change notification settings

Mayank-Tripathi32/Express-Starter-with-TS-JWT

Repository files navigation

Express Prisma Starter Template

License

How to use this template:

Includes API index utilities:

  • Prisma
    • ORM for Mysql schema generation and manupulation
  • Cron
    • For Sheduling the jobs to run.
  • Mysql
    • Database for storing data.
  • morgan
    • HTTP request logger middleware for node.js
  • helmet
    • Helmet helps you secure your Express apps by setting various HTTP headers. It's not a silver bullet, but it can help!
  • dotenv
    • Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env
  • cors
    • CORS is a node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options.

Development utilities:

  • nodemon
    • nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
  • eslint
    • ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
  • Typescript
    • For Tightly typing the codebase.

Work in progress

  • jest
    • Jest is a delightful JavaScript Testing Framework with a focus on simplicity.
  • supertest
    • HTTP assertions made easy via superagent.
  • Docker
    • Dockerize the whole application
  • cors
    • Add cron job for cleaning up blacklisted tokens every 2 days.

Setup

npm install

Test (wip)

npm test

Development

npm run dev

Project layout

The code for the microservice is contained in the src directory. All of the test are in the tests folder(wip). The code follows the Model-View-Controller pattern with all of the database code and business logic in the controler dir, and all of the RESTful routing (routes) Dir which supports sub folder routing.

├── documentation       <- template documentation files
├── src              <- microservice template
│   ├── controllers/    <- application controllers for routes <- microservice
│   ├── index.ts       <- express configuration file
│   ├── tests/          <- code for the testing various apis  //wip
│   └── routes/         <- code for the REST API routes
├── tsconfig.json       <- ts setup config
├── package.json        <- node setup config
├── .env.example        <- example setup env file
└── prisma                       <- prima ORM
    ├── schema.prisma            <- mysql schema
    └── migration/               <- migration schema

Data Model

The User model contains the following fields:

Name Type Optional
id Integer False
username String(64) False
email String(64) False
password String(32) False
role enum(role) False
created_at DateTime auto
updated_at DateTime auto

Role Enum

Name Optional
Subscriber default
ADMIN False
MANAGER False
#Note

Run npx prisma migrate dev --name init After updating database tables (ORM)

Author

Leave it Blank

Contributors

Mizety

License

Licensed under the Apache License. See LICENSE