Skip to content

Minyeng/wallet-api

Repository files navigation

API Wallet

A fast, lightweight, and secure API wallet services built using Express.js, PostgreSQL, and JWT authentication

⚙️ Tech Stack

  • Express.js (Objection, Knex, Joi, JWT)
  • PostgreSQL (Database)

📂 Project Structure

project-root/
├── controllers/
├── db/
├── migrations/
├── models/
├── repositories/
├── routes/
├── validators/
├── server.js
├── knexfile.js
├── auth.js
├── .env
└── package.json

📦 Getting Started

Install dependencies

  npm install

Set up environment variables

Create a .env file based on .env.example:

  PORT=5000
  DB_HOST=
  DB_PORT=
  DB_USER=
  DB_PASSWORD=
  DB_NAME=
  JWT_SECRET=

Run migrations

  npx knex migrate:latest

Start the development server

  npm run dev

🌐 API Endpoints

  1. GET /api/users/me
    content-type: application/json
    authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
    
  2. POST /api/users/register
    content-type: application/json
    

    { "username": "superadmin", "password": "Pas$w0rd" }

  3. POST /api/users/login
    content-type: application/json
    

    { "username": "superadmin", "password": "Pas$w0rd" }

  4. GET /api/wallet/
    content-type: application/json
    authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
    
  5. PUT /api/wallet/topup
    content-type: application/json
    authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
    

    { "amount": 1000000000000 }

  6. PUT /api/wallet/deduct
    content-type: application/json
    authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
    

    { "amount": 1000000000000 }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors