Skip to content

A NodeJS Restful API to deposit, transfer and withdraw money.

Notifications You must be signed in to change notification settings

qytela/WalletAPI

Repository files navigation

Restful API Wallet

A NodeJS Restful API to deposit, transfer and withdraw money.

Installation

  • Create database with name wallet_api or setting config database in folder /Config/Database.js :
// Config/Database.js

const db = require('knex')({
  client: 'mysql',
  connection: {
    host: 'localhost',
    user: 'YOUR_DATABASE_USERNAME',
    password: 'YOUR_DATABASE_PASSWORD',
    database: 'YOUR_DATABASE_NAME'
  }
});

module.exports = db;

Note: setting your migration config in knexfile.js :

// knexfile.js

development: {
    client: 'mysql',
    connection: {
      host: 'localhost',
      user: 'YOUR_DATABASE_USERNAME',
      password: 'YOUR_DATABASE_PASSWORD',
      database: 'YOUR_DATABASE_DATABASE'
    },
    migrations: {
      tableName: 'migrations'
    }
  }
  • Run Migration
$ knex migration:latest

Note: if you not installed knex, first run this command:

$ npm install knex --global

Security

Restful API Wallet using passport module for Authentication Route:

passport.authenticate('jwt', { session: false })

Use this header:

Authorization: Bearer <token>

How do i get Bearer Token ?

  • PATH:
POST /auth/login
  • Request Content-Type: Application/json

  • Request Body:

{
  "email": "[email protected]",
  "password": "example"
}
  • Response if login success:
{
  "status": true,
  "msg": "Login successfully.",
  "tk": "<token>"
}

License

ISC License.

About

A NodeJS Restful API to deposit, transfer and withdraw money.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published