From 8bf9e87117d7f22581d84eb2f440f05a9c34e72b Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 22 Jan 2019 21:42:05 +0900 Subject: [PATCH] Fix types --- src/server/api/api-handler.ts | 2 +- src/server/api/common/signin.ts | 2 +- src/server/api/private/signin.ts | 2 +- src/server/api/private/signup.ts | 2 +- src/server/api/service/discord.ts | 4 ++-- src/server/api/service/github.ts | 4 ++-- src/server/api/service/twitter.ts | 4 ++-- src/server/file/send-drive-file.ts | 8 ++++---- src/server/web/docs.ts | 2 +- src/server/web/index.ts | 8 ++++---- src/server/web/url-preview.ts | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/server/api/api-handler.ts b/src/server/api/api-handler.ts index 128c1a98d2..0eef9ab5c7 100644 --- a/src/server/api/api-handler.ts +++ b/src/server/api/api-handler.ts @@ -6,7 +6,7 @@ import call from './call'; import { IUser } from '../../models/user'; import { IApp } from '../../models/app'; -export default async (endpoint: IEndpoint, ctx: Koa.Context) => { +export default async (endpoint: IEndpoint, ctx: Koa.BaseContext) => { const body = ctx.is('multipart/form-data') ? (ctx.req as any).body : ctx.request.body; const reply = (x?: any, y?: any) => { diff --git a/src/server/api/common/signin.ts b/src/server/api/common/signin.ts index 45a42e288d..84cad3a935 100644 --- a/src/server/api/common/signin.ts +++ b/src/server/api/common/signin.ts @@ -3,7 +3,7 @@ import * as Koa from 'koa'; import config from '../../../config'; import { ILocalUser } from '../../../models/user'; -export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) { +export default function(ctx: Koa.BaseContext, user: ILocalUser, redirect = false) { if (redirect) { //#region Cookie const expires = 1000 * 60 * 60 * 24 * 365; // One Year diff --git a/src/server/api/private/signin.ts b/src/server/api/private/signin.ts index 0a0f9ae6f9..6292527843 100644 --- a/src/server/api/private/signin.ts +++ b/src/server/api/private/signin.ts @@ -7,7 +7,7 @@ import { publishMainStream } from '../../../stream'; import signin from '../common/signin'; import config from '../../../config'; -export default async (ctx: Koa.Context) => { +export default async (ctx: Koa.BaseContext) => { ctx.set('Access-Control-Allow-Origin', config.url); ctx.set('Access-Control-Allow-Credentials', 'true'); diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index 8766a4f2dd..b89629bcd1 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -9,7 +9,7 @@ import RegistrationTicket from '../../../models/registration-tickets'; import usersChart from '../../../chart/users'; import fetchMeta from '../../../misc/fetch-meta'; -export default async (ctx: Koa.Context) => { +export default async (ctx: Koa.BaseContext) => { const body = ctx.request.body as any; const instance = await fetchMeta(); diff --git a/src/server/api/service/discord.ts b/src/server/api/service/discord.ts index d90f39ffb3..1118e241d4 100644 --- a/src/server/api/service/discord.ts +++ b/src/server/api/service/discord.ts @@ -10,11 +10,11 @@ import uuid = require('uuid'); import signin from '../common/signin'; import fetchMeta from '../../../misc/fetch-meta'; -function getUserToken(ctx: Koa.Context) { +function getUserToken(ctx: Koa.BaseContext) { return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1]; } -function compareOrigin(ctx: Koa.Context) { +function compareOrigin(ctx: Koa.BaseContext) { function normalizeUrl(url: string) { return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : ''; } diff --git a/src/server/api/service/github.ts b/src/server/api/service/github.ts index 4dce856c2a..5934e96f63 100644 --- a/src/server/api/service/github.ts +++ b/src/server/api/service/github.ts @@ -10,11 +10,11 @@ import uuid = require('uuid'); import signin from '../common/signin'; import fetchMeta from '../../../misc/fetch-meta'; -function getUserToken(ctx: Koa.Context) { +function getUserToken(ctx: Koa.BaseContext) { return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1]; } -function compareOrigin(ctx: Koa.Context) { +function compareOrigin(ctx: Koa.BaseContext) { function normalizeUrl(url: string) { return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : ''; } diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts index ced3e8accd..ff7f985279 100644 --- a/src/server/api/service/twitter.ts +++ b/src/server/api/service/twitter.ts @@ -9,11 +9,11 @@ import config from '../../../config'; import signin from '../common/signin'; import fetchMeta from '../../../misc/fetch-meta'; -function getUserToken(ctx: Koa.Context) { +function getUserToken(ctx: Koa.BaseContext) { return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1]; } -function compareOrigin(ctx: Koa.Context) { +function compareOrigin(ctx: Koa.BaseContext) { function normalizeUrl(url: string) { return url.endsWith('/') ? url.substr(0, url.length - 1) : url; } diff --git a/src/server/file/send-drive-file.ts b/src/server/file/send-drive-file.ts index c64177d4ee..05d871a4c8 100644 --- a/src/server/file/send-drive-file.ts +++ b/src/server/file/send-drive-file.ts @@ -7,12 +7,12 @@ import DriveFileWebpublic, { getDriveFileWebpublicBucket } from '../../models/dr const assets = `${__dirname}/../../server/file/assets/`; -const commonReadableHandlerGenerator = (ctx: Koa.Context) => (e: Error): void => { +const commonReadableHandlerGenerator = (ctx: Koa.BaseContext) => (e: Error): void => { console.error(e); ctx.status = 500; }; -export default async function(ctx: Koa.Context) { +export default async function(ctx: Koa.BaseContext) { // Validate id if (!mongodb.ObjectID.isValid(ctx.params.id)) { ctx.throw(400, 'incorrect id'); @@ -26,13 +26,13 @@ export default async function(ctx: Koa.Context) { if (file == null) { ctx.status = 404; - await send(ctx, '/dummy.png', { root: assets }); + await send(ctx as any, '/dummy.png', { root: assets }); return; } if (file.metadata.deletedAt) { ctx.status = 410; - await send(ctx, '/tombstone.png', { root: assets }); + await send(ctx as any, '/tombstone.png', { root: assets }); return; } diff --git a/src/server/web/docs.ts b/src/server/web/docs.ts index f9991fc65c..94c18d9996 100644 --- a/src/server/web/docs.ts +++ b/src/server/web/docs.ts @@ -160,7 +160,7 @@ const extractPropDefRef = (props: any[]) => { const router = new Router(); router.get('/assets/*', async ctx => { - await send(ctx, ctx.params[0], { + await send(ctx as any, ctx.params[0], { root: `${__dirname}/../../docs/assets/`, maxage: ms('1 days') }); diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 945176afd3..69f3b8859f 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -51,7 +51,7 @@ const router = new Router(); //#region static assets router.get('/assets/*', async ctx => { - await send(ctx, ctx.path, { + await send(ctx as any, ctx.path, { root: client, maxage: ms('7 days'), immutable: true @@ -60,21 +60,21 @@ router.get('/assets/*', async ctx => { // Apple touch icon router.get('/apple-touch-icon.png', async ctx => { - await send(ctx, '/assets/apple-touch-icon.png', { + await send(ctx as any, '/assets/apple-touch-icon.png', { root: client }); }); // ServiceWorker router.get(/^\/sw\.(.+?)\.js$/, async ctx => { - await send(ctx, `/assets/sw.${ctx.params[0]}.js`, { + await send(ctx as any, `/assets/sw.${ctx.params[0]}.js`, { root: client }); }); // Manifest router.get('/manifest.json', async ctx => { - await send(ctx, '/assets/manifest.json', { + await send(ctx as any, '/assets/manifest.json', { root: client }); }); diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index 86ae3fa0a5..4cda5ecb01 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -3,7 +3,7 @@ import * as request from 'request-promise-native'; import summaly from 'summaly'; import fetchMeta from '../../misc/fetch-meta'; -module.exports = async (ctx: Koa.Context) => { +module.exports = async (ctx: Koa.BaseContext) => { const meta = await fetchMeta(); try {