Module Name
This is one basic module for integration.
Installation
$ npm install --save @jxding/db-ts-npm-test
Quick Start
import Koa from 'koa'
import {exportsFunc} from '@jxding/db-ts-npm-test'
function main() {
const app = new Koa();
exportsFunc(app,{"host":"10.0.16.25"});
app.listen('8889');
}
main();
Reference
exportFunc(app:koa, opts?:{})
this is the entry func.
app is a koa object;
opts is your db options:
{
host: '127.0.0.1',
port: 3307,
username: 'sunny_man',
password: 'qwer-sunnydev',
database: 'cleaner',
}
you can revise the default value to match your local db(only mysql), if not defined, the value will use the default value(above all).
API Reference
/api/user/login
/api/user/register
/api/user/revise
...
Use Token
all apis except for user-related need token verify
set header {token:tokenValue}
(if login success, token will be sent back, expire time 60s)