Fix types

This commit is contained in:
syuilo 2019-01-22 21:42:05 +09:00
parent 97e8ac1d27
commit 8bf9e87117
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
11 changed files with 20 additions and 20 deletions

View File

@ -6,7 +6,7 @@ import call from './call';
import { IUser } from '../../models/user'; import { IUser } from '../../models/user';
import { IApp } from '../../models/app'; 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 body = ctx.is('multipart/form-data') ? (ctx.req as any).body : ctx.request.body;
const reply = (x?: any, y?: any) => { const reply = (x?: any, y?: any) => {

View File

@ -3,7 +3,7 @@ import * as Koa from 'koa';
import config from '../../../config'; import config from '../../../config';
import { ILocalUser } from '../../../models/user'; 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) { if (redirect) {
//#region Cookie //#region Cookie
const expires = 1000 * 60 * 60 * 24 * 365; // One Year const expires = 1000 * 60 * 60 * 24 * 365; // One Year

View File

@ -7,7 +7,7 @@ import { publishMainStream } from '../../../stream';
import signin from '../common/signin'; import signin from '../common/signin';
import config from '../../../config'; 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-Origin', config.url);
ctx.set('Access-Control-Allow-Credentials', 'true'); ctx.set('Access-Control-Allow-Credentials', 'true');

View File

@ -9,7 +9,7 @@ import RegistrationTicket from '../../../models/registration-tickets';
import usersChart from '../../../chart/users'; import usersChart from '../../../chart/users';
import fetchMeta from '../../../misc/fetch-meta'; 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 body = ctx.request.body as any;
const instance = await fetchMeta(); const instance = await fetchMeta();

View File

@ -10,11 +10,11 @@ import uuid = require('uuid');
import signin from '../common/signin'; import signin from '../common/signin';
import fetchMeta from '../../../misc/fetch-meta'; 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]; return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
} }
function compareOrigin(ctx: Koa.Context) { function compareOrigin(ctx: Koa.BaseContext) {
function normalizeUrl(url: string) { function normalizeUrl(url: string) {
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : ''; return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
} }

View File

@ -10,11 +10,11 @@ import uuid = require('uuid');
import signin from '../common/signin'; import signin from '../common/signin';
import fetchMeta from '../../../misc/fetch-meta'; 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]; return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
} }
function compareOrigin(ctx: Koa.Context) { function compareOrigin(ctx: Koa.BaseContext) {
function normalizeUrl(url: string) { function normalizeUrl(url: string) {
return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : ''; return url ? url.endsWith('/') ? url.substr(0, url.length - 1) : url : '';
} }

View File

@ -9,11 +9,11 @@ import config from '../../../config';
import signin from '../common/signin'; import signin from '../common/signin';
import fetchMeta from '../../../misc/fetch-meta'; 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]; return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
} }
function compareOrigin(ctx: Koa.Context) { function compareOrigin(ctx: Koa.BaseContext) {
function normalizeUrl(url: string) { function normalizeUrl(url: string) {
return url.endsWith('/') ? url.substr(0, url.length - 1) : url; return url.endsWith('/') ? url.substr(0, url.length - 1) : url;
} }

View File

@ -7,12 +7,12 @@ import DriveFileWebpublic, { getDriveFileWebpublicBucket } from '../../models/dr
const assets = `${__dirname}/../../server/file/assets/`; 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); console.error(e);
ctx.status = 500; ctx.status = 500;
}; };
export default async function(ctx: Koa.Context) { export default async function(ctx: Koa.BaseContext) {
// Validate id // Validate id
if (!mongodb.ObjectID.isValid(ctx.params.id)) { if (!mongodb.ObjectID.isValid(ctx.params.id)) {
ctx.throw(400, 'incorrect id'); ctx.throw(400, 'incorrect id');
@ -26,13 +26,13 @@ export default async function(ctx: Koa.Context) {
if (file == null) { if (file == null) {
ctx.status = 404; ctx.status = 404;
await send(ctx, '/dummy.png', { root: assets }); await send(ctx as any, '/dummy.png', { root: assets });
return; return;
} }
if (file.metadata.deletedAt) { if (file.metadata.deletedAt) {
ctx.status = 410; ctx.status = 410;
await send(ctx, '/tombstone.png', { root: assets }); await send(ctx as any, '/tombstone.png', { root: assets });
return; return;
} }

View File

@ -160,7 +160,7 @@ const extractPropDefRef = (props: any[]) => {
const router = new Router(); const router = new Router();
router.get('/assets/*', async ctx => { router.get('/assets/*', async ctx => {
await send(ctx, ctx.params[0], { await send(ctx as any, ctx.params[0], {
root: `${__dirname}/../../docs/assets/`, root: `${__dirname}/../../docs/assets/`,
maxage: ms('1 days') maxage: ms('1 days')
}); });

View File

@ -51,7 +51,7 @@ const router = new Router();
//#region static assets //#region static assets
router.get('/assets/*', async ctx => { router.get('/assets/*', async ctx => {
await send(ctx, ctx.path, { await send(ctx as any, ctx.path, {
root: client, root: client,
maxage: ms('7 days'), maxage: ms('7 days'),
immutable: true immutable: true
@ -60,21 +60,21 @@ router.get('/assets/*', async ctx => {
// Apple touch icon // Apple touch icon
router.get('/apple-touch-icon.png', async ctx => { 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 root: client
}); });
}); });
// ServiceWorker // ServiceWorker
router.get(/^\/sw\.(.+?)\.js$/, async ctx => { 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 root: client
}); });
}); });
// Manifest // Manifest
router.get('/manifest.json', async ctx => { router.get('/manifest.json', async ctx => {
await send(ctx, '/assets/manifest.json', { await send(ctx as any, '/assets/manifest.json', {
root: client root: client
}); });
}); });

View File

@ -3,7 +3,7 @@ import * as request from 'request-promise-native';
import summaly from 'summaly'; import summaly from 'summaly';
import fetchMeta from '../../misc/fetch-meta'; import fetchMeta from '../../misc/fetch-meta';
module.exports = async (ctx: Koa.Context) => { module.exports = async (ctx: Koa.BaseContext) => {
const meta = await fetchMeta(); const meta = await fetchMeta();
try { try {