From f35547f3b8fef605a3ba34136a87f83cddb5f49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Thu, 31 Jan 2019 23:32:58 +0900 Subject: [PATCH] API modules as import syntax (#4069) --- src/server/api/index.ts | 18 +++++++++++------- src/server/api/service/discord.ts | 2 +- src/server/api/service/github.ts | 2 +- src/server/api/service/twitter.ts | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/server/api/index.ts b/src/server/api/index.ts index 17a2579f2..c9e1107fc 100644 --- a/src/server/api/index.ts +++ b/src/server/api/index.ts @@ -9,8 +9,12 @@ import * as bodyParser from 'koa-bodyparser'; const cors = require('@koa/cors'); import endpoints from './endpoints'; - -const handler = require('./api-handler').default; +import handler from './api-handler'; +import signup from './private/signup'; +import signin from './private/signup'; +import discord from './service/discord'; +import github from './service/github'; +import twitter from './service/twitter'; // Init app const app = new Koa(); @@ -49,12 +53,12 @@ for (const endpoint of endpoints) { } } -router.post('/signup', require('./private/signup').default); -router.post('/signin', require('./private/signin').default); +router.post('/signup', signup); +router.post('/signin', signin); -router.use(require('./service/discord').routes()); -router.use(require('./service/github').routes()); -router.use(require('./service/twitter').routes()); +router.use(discord.routes()); +router.use(github.routes()); +router.use(twitter.routes()); // Return 404 for unknown API router.all('*', async ctx => { diff --git a/src/server/api/service/discord.ts b/src/server/api/service/discord.ts index 1118e241d..d7a3b93ac 100644 --- a/src/server/api/service/discord.ts +++ b/src/server/api/service/discord.ts @@ -303,4 +303,4 @@ router.get('/dc/cb', async ctx => { } }); -module.exports = router; +export default router; diff --git a/src/server/api/service/github.ts b/src/server/api/service/github.ts index 5934e96f6..e26a22599 100644 --- a/src/server/api/service/github.ts +++ b/src/server/api/service/github.ts @@ -271,4 +271,4 @@ router.get('/gh/cb', async ctx => { } }); -module.exports = router; +export default router; diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts index ff7f98527..f7f023d82 100644 --- a/src/server/api/service/twitter.ts +++ b/src/server/api/service/twitter.ts @@ -185,4 +185,4 @@ router.get('/tw/cb', async ctx => { } }); -module.exports = router; +export default router;