Skip to content

Latest commit

 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express-API

This project builds a backend in Express by implementing simple REST APIs for authentication and users.

Project Structure

/src
├── index.ts                  # Server entry point
├── db
│   └── users.ts              # User model + DB CRUD functions
├── helpers
│   └── index.ts              # Password hashing, salt generation, etc
├── middlewares
│   └── index.ts              # Authentication / Authorization middleware
├── router
│   ├── index.ts              # Combines all routers
│   ├── authentication.ts     # Auth routes
│   └── users.ts              # User routes
└── controllers               # Business logic
    ├── authentication.ts  
    └── users.ts           

Component Roles

Component Roles
index.ts Initialises the Express app, sets up the global middlewares, starts HTTP server, connects to the MongoDB database
db/users.ts Defines MongoDB User schema and provides CRUD functions
helpers/index.ts Handles password hashing, salt/pepper generation, security utilities
middlewares/index.ts Implements authentication and authorization middlewares
router/index.ts Combines all individual routers and exports the main router
router/authentication.ts Defines /auth routes
router/users.ts Defines /users routes for CRUD operations
controllers/authentication.ts Handles register/login logic, cookie creation, password verification
controllers/users.ts Handles user retrieval, deletion, and updates

Architecture Flow Diagram

image

About

Building Backend and REST APIs with Express and TypeScript

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages