Web Application: GitHub Pages Deployment
POST /auth/register
POST /auth/login
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
- 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
curl -X POST https://imf-gadgets-api-demo.onrender.com/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"put username","password":"put password"}'curl -X POST https://imf-gadgets-api-demo.onrender.com/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"agent009","password":"secret009"}'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"}'curl -X GET https://imf-gadgets-api-demo.onrender.com/gadgets \
-H "Authorization: Bearer YOUR_JWT_TOKEN"curl -X GET https://imf-gadgets-api-demo.onrender.com/gadgets?status=Available \
-H "Authorization: Bearer YOUR_JWT_TOKEN"POST /auth/register
Content-Type: application/json
{
"username": "agent007",
"password": "secretpassword"
}POST /auth/login
Content-Type: application/json
{
"username": "agent007",
"password": "secretpassword"
}GET /gadgets
Authorization: Bearer <jwt_token>GET /gadgets?status=Available
Authorization: Bearer <jwt_token>
Available status values: "Available", "Deployed", "Destroyed", "Decommissioned"POST /gadgets
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"name": "Explosive Chewing Gum",
"status": "Available"
}PATCH /gadgets/:id
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"status": "Deployed"
}DELETE /gadgets/:id
Authorization: Bearer <jwt_token>POST /gadgets/:id/self-destruct
Authorization: Bearer <jwt_token>- 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
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
-
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
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
This project is licensed under the MIT License - see the LICENSE.md file for details.