A fast, lightweight, and secure API wallet services built using Express.js, PostgreSQL, and JWT authentication
- Express.js (Objection, Knex, Joi, JWT)
- PostgreSQL (Database)
project-root/
├── controllers/
├── db/
├── migrations/
├── models/
├── repositories/
├── routes/
├── validators/
├── server.js
├── knexfile.js
├── auth.js
├── .env
└── package.json
npm install
Create a .env file based on .env.example:
PORT=5000 DB_HOST= DB_PORT= DB_USER= DB_PASSWORD= DB_NAME= JWT_SECRET=
npx knex migrate:latest
npm run dev
GET /api/users/me content-type: application/json authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
POST /api/users/register content-type: application/json
{ "username": "superadmin", "password": "Pas$w0rd" }
POST /api/users/login content-type: application/json
{ "username": "superadmin", "password": "Pas$w0rd" }
GET /api/wallet/ content-type: application/json authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
PUT /api/wallet/topup content-type: application/json authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
{ "amount": 1000000000000 }
PUT /api/wallet/deduct content-type: application/json authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
{ "amount": 1000000000000 }