A NodeJS Restful API to deposit, transfer and withdraw money.
- 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
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>"
}
ISC License.