59 lines
1.3 KiB
JavaScript
59 lines
1.3 KiB
JavaScript
const Router = require('@koa/router');
|
|
const joi = require('joi');
|
|
const commonCtrl = require('src/controllers/common/index.js');
|
|
const accCtrl = require('src/controllers/account/index.js');
|
|
|
|
const r = new Router({ prefix: '/api' });
|
|
module.exports = r;
|
|
|
|
// set api handler middleware
|
|
r.use(commonCtrl.apiHandler());
|
|
|
|
/**
|
|
* get account info
|
|
* @swagger
|
|
* @route GET /api/login
|
|
* @group account - account apis
|
|
* @param {string} back_url.query.required - back to url
|
|
* @returns {RespDefault.model} default -
|
|
*/
|
|
r.get(
|
|
'/login',
|
|
commonCtrl.validate({
|
|
query: {
|
|
back_url: joi.string().required(),
|
|
},
|
|
}),
|
|
accCtrl.loginSSO()
|
|
);
|
|
|
|
/**
|
|
* account refresh token
|
|
* @swagger
|
|
* @route POST /api/refresh
|
|
* @group account - account apis
|
|
* @security JWT
|
|
* @returns {RespDefault.model} default -
|
|
*/
|
|
r.post('/refresh', commonCtrl.authorization(true), accCtrl.logout());
|
|
|
|
/**
|
|
* account logout
|
|
* @swagger
|
|
* @route POST /api/logout
|
|
* @group account - account apis
|
|
* @security JWT
|
|
* @returns {RespDefault.model} default -
|
|
*/
|
|
r.post('/logout', commonCtrl.authorization(false), accCtrl.logout());
|
|
|
|
/**
|
|
* account get info
|
|
* @swagger
|
|
* @route GET /api/userinfo
|
|
* @group account - account apis
|
|
* @security JWT
|
|
* @returns {RespDefault.model} default -
|
|
*/
|
|
r.get('/userinfo', commonCtrl.authorization(false), accCtrl.getInfo());
|