Skip to content

ctrlshift-hash/nodejs-express-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Backend API

A high-performance, scalable RESTful API built with Node.js, Express, TypeScript, and WebSocket support. Features authentication, real-time capabilities, database integration, and comprehensive error handling.

Features

  • RESTful API - Clean REST endpoints with Express.js
  • WebSocket Server - Real-time bidirectional communication
  • Authentication - JWT-based authentication with refresh tokens
  • Database - MongoDB with Mongoose ODM
  • TypeScript - Full type safety and modern ES features
  • Validation - Request validation with Joi/Zod
  • Error Handling - Centralized error handling middleware
  • Rate Limiting - API rate limiting and throttling
  • Logging - Structured logging with Winston
  • Testing - Unit and integration tests with Jest
  • Docker - Containerized deployment

Tech Stack

  • Node.js 18+ - Runtime
  • Express.js - Web framework
  • TypeScript - Language
  • MongoDB - Database
  • Mongoose - ODM
  • Socket.io - WebSocket library
  • JWT - Authentication
  • Winston - Logging
  • Jest - Testing
  • ESLint - Linting

Installation

npm install

Running

# Development
npm run dev

# Production
npm run build
npm start

# With Docker
docker-compose up

API Endpoints

POST   /api/auth/register    - Register user
POST   /api/auth/login       - Login
POST   /api/auth/refresh     - Refresh token
GET    /api/users           - Get users
GET    /api/users/:id       - Get user
POST   /api/users           - Create user
PUT    /api/users/:id       - Update user
DELETE /api/users/:id       - Delete user

WebSocket: ws://localhost:3000

Project Structure

nodejs-backend-api/
├── src/
│   ├── controllers/        # Route controllers
│   ├── models/            # Database models
│   ├── routes/            # API routes
│   ├── middleware/        # Custom middleware
│   ├── services/          # Business logic
│   ├── utils/            # Utilities
│   ├── config/           # Configuration
│   ├── websocket/        # WebSocket handlers
│   └── app.ts            # Express app
├── tests/                # Test files
└── docker/               # Docker files

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published