Skip to content

needkg/node-api-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Node.js API Template

Node.js Express.js MySQL JWT

🚀 Quick Start

# Clone and setup
git clone https://github.com/needkg/node-api-template.git
cd node-api-template
npm install

# Configure environment
cp .env.example .env
# Edit .env with your database credentials

# Start development server
npm run dev

✨ Features

  • 🔐 JWT Authentication with refresh tokens
  • 👥 User Management with role-based access
  • 🛡️ Security First - bcrypt, prepared statements, CORS
  • 🏗️ Modular Architecture - clean, maintainable code
  • 🗄️ MySQL Integration - connection pooling & auto-setup
  • 🔄 Hot Reload - fast development with nodemon

📋 API Endpoints

🔐 Authentication

Method Endpoint Description Authentication
POST /auth/register Register new user
POST /auth/login User login
POST /auth/refresh Refresh access token
POST /auth/logout User logout

👤 Users

Method Endpoint Description Authentication
GET /user/me Get user profile
PATCH /user/me Update profile

👑 Administration

Method Endpoint Description Authentication
GET /admin/users List all users ✅ Admin
POST /admin/users/create Create user ✅ Admin
PATCH /admin/users/:uuid Update user ✅ Admin

⚙️ Setup

Method Endpoint Description Authentication
POST /setup/first-admin Create first administrator

📡 API Endpoints Documentation → (cooming soon)

🛡️ Security

  • Password Hashing with bcrypt
  • JWT Tokens for stateless authentication
  • SQL Injection Protection with prepared statements
  • Role-based Access Control
  • Secure Cookie Handling

📄 License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors