Skip to content

About

NodeJS RESTful API Microservice

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

NodeJS Authentication Microservice

This repository contains a minimal Node.js RESTful microservice that implements user authentication and authorization using Express, MongoDB (Mongoose), bcrypt, and JWT.

Features

  • Register and login with email/password
  • Password hashing with bcrypt
  • JWT access tokens
  • Role-based authorization (user/admin)
  • Protected route example
  • Ready for Docker

Quick start

  1. Copy .env.example to .env and set MONGO_URI and JWT_SECRET.
  2. npm install
  3. npm run dev

API Endpoints

  • POST /api/auth/register { name, email, password }
  • POST /api/auth/login { email, password }
  • GET /api/auth/me (protected)
  • GET /api/users (protected, admin only)

Environment variables (.env)

  • MONGO_URI - MongoDB connection string
  • JWT_SECRET - secret used to sign JWTs
  • PORT - optional server port (default 3000)

Docker

  • Build: docker build -t nodejs-microservice .
  • Run: docker run -e MONGO_URI="..." -e JWT_SECRET="..." -p 3000:3000 nodejs-microservice

About

NodeJS RESTful API Microservice

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages