A RESTful API built with Node.js, Express, TypeScript, and Prisma for managing gadgets and user authentication.
- 🔐 JWT-based Authentication & Authorization
- 👤 User Management (Agents & Admins)
- 🔧 Gadget Management System
- 📝 PostgreSQL Database with Prisma ORM
- 🚀 TypeScript Support
- ⚡ Fast Development Setup
- Node.js (v14 or higher)
- PostgreSQL Database
- npm or yarn package manager
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- ORM: Prisma
- Database: PostgreSQL
- Authentication: JWT (JSON Web Tokens)
- Clone the repository:
git clone <repository-url>
cd upraised
- Install dependencies:
npm install
- Set up environment variables:
Create a
.env
file in the root directory with the following variables:
DATABASE_URL="postgresql://username:password@localhost:5432/database_name"
JWT_SECRET="your-jwt-secret"
PORT=3000
- Generate Prisma client and run migrations:
npm run prisma:generate
npm run prisma:migrate
- Start the development server:
npm run dev
npm run dev
- Start development server with hot-reloadnpm run build
- Build the project for productionnpm start
- Start production servernpm run prisma:generate
- Generate Prisma clientnpm run prisma:migrate
- Run database migrations
POST /api/auth/register
- Register a new userPOST /api/auth/login
- Login user
GET /api/gadgets
- Get all gadgetsGET /api/gadgets/:id
- Get a specific gadgetPOST /api/gadgets
- Create a new gadgetPUT /api/gadgets/:id
- Update a gadgetDELETE /api/gadgets/:id
- Delete a gadget
id
: UUIDusername
: String (unique)password
: String (hashed)role
: Enum (AGENT, ADMIN)createdAt
: DateTimeupdatedAt
: DateTime
id
: UUIDcodename
: String (unique)name
: Stringstatus
: Enum (Available, Deployed, Destroyed, Decommissioned)decommissionedAt
: DateTime (optional)createdAt
: DateTimeupdatedAt
: DateTime
- Password hashing using bcrypt
- JWT-based authentication
- Role-based access control
- Environment variables for sensitive data
The API includes a centralized error handling middleware that processes all errors and returns appropriate HTTP status codes and error messages.
The project uses ts-node-dev
for development, which provides hot-reload functionality. The TypeScript configuration is set up to ensure type safety throughout the application.