Skip to content

A secure API system built for the Impossible Missions Force (IMF) to manage their high-tech gadget inventory. This project includes a Node.js/Express backend API with PostgreSQL database and JWT authentication.

License

Notifications You must be signed in to change notification settings

yadnyeshkolte/imf-gadgets-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

IMF Gadget Management System API

Web Application: GitHub Pages Deployment

πŸ“‹ API Features

Authentication Endpoints

POST /auth/register
POST /auth/login

Gadget Management Endpoints

GET    /gadgets          - Retrieve all gadgets
GET    /gadgets?status={status} - Filter gadgets by status
POST   /gadgets          - Add new gadget (auto-generates codename)
PATCH  /gadgets/:id      - Update gadget information
DELETE /gadgets/:id      - Decommission gadget
POST   /gadgets/:id/request-destruction - Get the Code
POST   /gadgets/:id/self-destruct - Initiate gadget self-destruct sequence

Key Features

  • JWT-based authentication system
  • Random codename generation (e.g., "The Nightingale", "Operation Kraken")
  • Mission success probability calculation
  • Status tracking (Available, Deployed, Destroyed, Decommissioned)
  • Soft delete implementation with decommission timestamps
  • Status-based filtering of gadgets

πŸ“ API Documentation

CURL Examples

Register New Agent

curl -X POST https://imf-gadgets-api-demo.onrender.com/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username":"put username","password":"put password"}'

Login

curl -X POST https://imf-gadgets-api-demo.onrender.com/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"agent009","password":"secret009"}'

Add New Gadget

curl -X POST https://imf-gadgets-api-demo.onrender.com/gadgets \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{"name":"Explosive Pen"}'

Get All Gadgets

curl -X GET https://imf-gadgets-api-demo.onrender.com/gadgets \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Get Gadgets by Status

curl -X GET https://imf-gadgets-api-demo.onrender.com/gadgets?status=Available \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

API Endpoints Detail

Postman

Authentication

Register New Agent
POST /auth/register
Content-Type: application/json

{
  "username": "agent007",
  "password": "secretpassword"
}
Login
POST /auth/login
Content-Type: application/json

{
  "username": "agent007",
  "password": "secretpassword"
}

Gadget Operations

Get All Gadgets
GET /gadgets
Authorization: Bearer <jwt_token>
Get Gadgets by Status
GET /gadgets?status=Available
Authorization: Bearer <jwt_token>

Available status values: "Available", "Deployed", "Destroyed", "Decommissioned"
Add New Gadget
POST /gadgets
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "name": "Explosive Chewing Gum",
  "status": "Available"
}
Update Gadget
PATCH /gadgets/:id
Authorization: Bearer <jwt_token>
Content-Type: application/json

{
  "status": "Deployed"
}
Decommission Gadget
DELETE /gadgets/:id
Authorization: Bearer <jwt_token>
Self-Destruct Gadget
POST /gadgets/:id/self-destruct
Authorization: Bearer <jwt_token>

πŸ› οΈ Tech Stack

Backend

  • Node.js
  • Express.js
  • PostgreSQL (hosted on Render.com)
  • Sequelize ORM
  • JSON Web Tokens (JWT) for authentication
  • bcrypt.js for password hashing
  • UUID for unique identifiers

Frontend (Separate Repository)

Environment Variables

Create a .env file with the following variables:

DATABASE_URL=your_postgres_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=3000
CORS_ORIGIN=http://localhost:5176,https://your-frontend-domain.com

πŸ” Features

  • JWT-based authentication

  • Password hashing using bcrypt

  • CORS configuration for specified origins

  • Protected routes using authentication middleware

  • Secure database connection with SSL in production

  • βœ… Deployment on Render.com

  • βœ… Status-based gadget filtering

  • βœ… Frontend implementation

  • βœ… CORS configuration for secure cross-origin requests

πŸ“¦ Deployment

The API is deployed on Render.com with the following configuration:

  • PostgreSQL database instance
  • Web service for the Node.js application
  • Environment variables configured in Render dashboard
  • Automatic deployments from GitHub

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

A secure API system built for the Impossible Missions Force (IMF) to manage their high-tech gadget inventory. This project includes a Node.js/Express backend API with PostgreSQL database and JWT authentication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published