1.0.2
This commit is contained in:
@ -1,31 +1,39 @@
|
||||
export let Get = (ctx) => {
|
||||
export const Get = (ctx, next) => {
|
||||
ctx.body = {
|
||||
result: 'get',
|
||||
name: ctx.params.name,
|
||||
para: ctx.query
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export let Post = async (ctx) => {
|
||||
export const Post = async (ctx, next) => {
|
||||
ctx.body = {
|
||||
result: 'post',
|
||||
name: ctx.params.name,
|
||||
para: ctx.request.body
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export let Put = (ctx) => {
|
||||
export const Put = (ctx, next) => {
|
||||
ctx.body = {
|
||||
result: 'put',
|
||||
name: ctx.params.name,
|
||||
para: ctx.request.body
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
export let Delete = (ctx) => {
|
||||
export const Delete = (ctx, next) => {
|
||||
ctx.body = {
|
||||
result: 'delete',
|
||||
name: ctx.params.name,
|
||||
para: ctx.request.body
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ const publicKey = fs.readFileSync(path.join(__dirname, '../../publicKey.pub'))
|
||||
/**
|
||||
* 检查授权是否合法
|
||||
*/
|
||||
export let CheckAuth = (ctx) => {
|
||||
const CheckAuth = (ctx, next) => {
|
||||
let token = ctx.request.header.authorization
|
||||
try {
|
||||
let decoded = jwt.verify(token.substr(7), publicKey)
|
||||
@ -39,11 +39,11 @@ export let CheckAuth = (ctx) => {
|
||||
}
|
||||
}
|
||||
|
||||
export let Post = (ctx) => {
|
||||
export const Post = (ctx, next) => {
|
||||
switch (ctx.params.action) {
|
||||
case 'check':
|
||||
return CheckAuth(ctx).then(result => { ctx.body = result })
|
||||
return CheckAuth(ctx).then(result => { ctx.body = result; next() })
|
||||
default:
|
||||
return CheckAuth(ctx).then(result => { ctx.body = result })
|
||||
return CheckAuth(ctx).then(result => { ctx.body = result; next() })
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,9 @@
|
||||
let requireDirectory = require('require-directory')
|
||||
module.exports = requireDirectory(module)
|
||||
import upload from './upload'
|
||||
import * as api from './api'
|
||||
import * as auth from './auth'
|
||||
|
||||
export default {
|
||||
upload,
|
||||
api,
|
||||
auth
|
||||
}
|
||||
|
Reference in New Issue
Block a user