Skip to content

AmanManhas20/-REST-API-with-Authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backend Developer Assignment

This project implements the core asks from the assignment PDF:

  • user registration and login
  • password hashing and JWT authentication
  • role-based access (user and admin)
  • CRUD APIs for a secondary entity (notes)
  • versioned REST endpoints under /api/v1
  • input validation and structured error handling
  • API documentation and a frontend UI

Stack

  • Backend: Node.js built-in http server
  • Auth: crypto.scrypt password hashing and HS256 token signing
  • Frontend: static HTML, CSS, and JavaScript
  • Demo persistence: local JSON file in data/database.json
  • Production-ready schema reference: docs/schema.sql

Run

node server.js

Then open:

  • http://localhost:3000/
  • http://localhost:3000/api/v1/health
  • http://localhost:3000/api-docs

Main Endpoints

  • POST /api/v1/auth/register
  • POST /api/v1/auth/login
  • GET /api/v1/auth/me
  • GET /api/v1/admin/users
  • GET /api/v1/notes
  • POST /api/v1/notes
  • GET /api/v1/notes/:id
  • PATCH /api/v1/notes/:id
  • DELETE /api/v1/notes/:id

Example Payloads

Register:

{
  "name": "Aarav Singh",
  "email": "aarav@example.com",
  "password": "securepass123",
  "role": "admin"
}

Create note:

{
  "title": "API hardening",
  "content": "Add rate limiting and audit logs.",
  "status": "active"
}

Notes

  • The frontend stores the token only in browser memory for this demo.
  • The assignment requested a database schema, so a PostgreSQL version is included in docs/schema.sql.
  • The supplied .site file was used as visual direction for the dashboard styling.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors