UNPKG

1 kBTypeScriptView Raw
1import Koa, { Next } from 'koa';
2import { Server } from 'http';
3import { Application as FeathersApplication, HookContext, Params, RouteLookup } from '@feathersjs/feathers';
4import '@feathersjs/authentication';
5export type ApplicationAddons = {
6 server: Server;
7 listen(port?: number, ...args: any[]): Promise<Server>;
8};
9export type Application<T = any, C = any> = Omit<Koa, 'listen'> & FeathersApplication<T, C> & ApplicationAddons;
10export type FeathersKoaContext<A = Application> = Koa.Context & {
11 app: A;
12};
13export type Middleware<A = Application> = (context: FeathersKoaContext<A>, next: Next) => any;
14declare module '@feathersjs/feathers/lib/declarations' {
15 interface ServiceOptions {
16 koa?: {
17 before?: Middleware[];
18 after?: Middleware[];
19 composed?: Middleware;
20 };
21 }
22}
23declare module 'koa' {
24 interface ExtendableContext {
25 feathers?: Partial<Params>;
26 lookup?: RouteLookup;
27 hook?: HookContext;
28 }
29}