我在通过路径传递对象时遇到问题,这是我的server.js
var jwt = require('jsonwebtoken');
var socketioJwt = require('socketio-jwt');
var app = require('koa')();
var server = require('http').createServer(app.callback());
var io = require('socket.io')(server);
var socket = require('./api/lib/socket.js')(app,io,socketioJwt);
var router = require('./api/router');
app.use(views('views', {map:{html:'swig'}}));
router(app,jwt);
这是我的routes.js
var route = require('koa-route');
module.exports = function router(app,jwt)
{
app.use(route.post('/login/auth', require('./routes/auth')(jwt));
};
这是我的身份证明:
module.exports = function *(jwt) {
var profile = {
first_name: 'a',
last_name: 'b',
email: 'a@gb.com',
id: 0
};
var input = this.request.body;
var token = jwt.sign(profile, input.password, { expiresIn: 60*5 });
this.cookies.set('access_token', token, { signed: false });
this.body = token;
};
问题是我得到了喷射:status code must be a number
错误在哪里?