mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-30 17:43:09 +02:00
Fix types
This commit is contained in:
parent
97e8ac1d27
commit
8bf9e87117
11 changed files with 20 additions and 20 deletions
|
@ -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) => {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 : '';
|
||||
}
|
||||
|
|
|
@ -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 : '';
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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')
|
||||
});
|
||||
|
|
|
@ -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
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue