Fix typescript

This commit is contained in:
syuilo 2017-08-10 22:06:47 +09:00
parent d48e7780dc
commit 84d0ad12d1
3 changed files with 11 additions and 4 deletions

View file

@ -45,7 +45,9 @@ app.post('/signup', require('./private/signup').default);
app.post('/signin', require('./private/signin').default); app.post('/signin', require('./private/signin').default);
app.use((req, res, next) => { app.use((req, res, next) => {
res.locals.user = ((req.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1]; // req.headers['cookie'] は常に string ですが、型定義の都合上
// string | string[] になっているので string を明示しています
res.locals.user = ((req.headers['cookie'] as string || '').match(/i=(!\w+)/) || [null, null])[1];
next(); next();
}); });

View file

@ -22,8 +22,11 @@ module.exports = async (app: express.Application) => {
const handler = new EventEmitter(); const handler = new EventEmitter();
app.post('/hooks/github', (req, res, next) => { app.post('/hooks/github', (req, res, next) => {
if ((new Buffer(req.headers['x-hub-signature'])).equals(new Buffer(`sha1=${crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')}`))) { // req.headers['x-hub-signature'] および
handler.emit(req.headers['x-github-event'], req.body); // req.headers['x-github-event'] は常に string ですが、型定義の都合上
// string | string[] になっているので string を明示しています
if ((new Buffer(req.headers['x-hub-signature'] as string)).equals(new Buffer(`sha1=${crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')}`))) {
handler.emit(req.headers['x-github-event'] as string, req.body);
res.sendStatus(200); res.sendStatus(200);
} else { } else {
res.sendStatus(400); res.sendStatus(400);

View file

@ -140,7 +140,9 @@ function spawnWorkers(onComplete: Function) {
} }
// On all workers started // On all workers started
progress.on('complete', onComplete); progress.on('complete', () => {
onComplete();
});
} }
// Listen new workers // Listen new workers