Skip to content

A starter for building production-ready RESTful APIs using Node.js, Express, and Prisma

License

Notifications You must be signed in to change notification settings

likui628/node-ts-express-starter

Repository files navigation

node-ts-express-starter

A boilerplate/starter project for quickly building RESTful APIs using Node.js, Express, and Prisma.

Installation

Clone the repo:

git clone --depth 1 https://github.com/likui628/node-ts-express-starter.git
cd node-ts-express-starter
npx rimraf ./.git

Install the dependencies:

npm install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Features

  • Authentication and authorization: using passport
  • Validation: request data validation using zod
  • Logging: using winston and morgan
  • Security: set security HTTP headers using helmet
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • Linting: with ESLint and Prettier

Project Structure

prisma\
 |--schema.prisma\  # Prisma schema file
 |--seed.ts\        # Prisma seed file  
src\
 |--config\         # Environment variables and configuration related things
 |--controllers\    # Route controllers (controller layer)
 |--middlewares\    # Custom express middlewares
 |--types\          # Type definitions
 |--services\       # Business logic (service layer)
 |--utils\          # Utility classes and functions
 |--validations\    # Request data validation schemas
 |--app.ts          # Express app
 |--index.ts        # App entry point

API Documentation

API Endpoints

List of available routes:

Auth routes:
POST /v1/auth/register - register
POST /v1/auth/login - login
POST /v1/auth/refresh - refresh auth tokens
POST /v1/auth/logout - logout\

User routes:
POST /v1/users - create a user
GET /v1/users - get all users
GET /v1/users/:userId - get user
PATCH /v1/users/:userId - update user
DELETE /v1/users/:userId - delete user

Acknowledgment

License

MIT

About

A starter for building production-ready RESTful APIs using Node.js, Express, and Prisma

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published