diff --git a/extensions/api.d.ts b/extensions/api.d.ts new file mode 100644 index 000000000..863519e20 --- /dev/null +++ b/extensions/api.d.ts @@ -0,0 +1,40 @@ +import type { RequestHandler } from 'express'; + +declare global { + namespace Express { + interface Request { + actor: any; // TODO + } + } +} + +type EndpointOptions = { + allowedMethods?: string[] + subdomain?: string + noauth?: boolean +} + +type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch'; + +type AddRouteFunction = (path: string, options: EndpointOptions, handler: RequestHandler) => void + +type RouterMethods = { + [K in HttpMethod]: { + (path: string, options: EndpointOptions, handler: RequestHandler): void; + (path: string, handler: RequestHandler, options?: EndpointOptions): void; + }; +} + +interface Extension extends RouterMethods { + // import(module: 'core'): { + // UserActorType: typeof UserActorType; + // }; + import(module: string): any; +} + +declare global { + // Declare the extension variable + const extension: Extension; +} + +export {}; diff --git a/extensions/jsconfig.json b/extensions/jsconfig.json new file mode 100644 index 000000000..0da51fce3 --- /dev/null +++ b/extensions/jsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "moduleResolution": "node", + "baseUrl": ".", + "paths": { + "../src/*": ["../src/*"] + }, + "allowJs": true, + "checkJs": true + }, + "include": [ + "**/*.js", + "**/*.d.ts" + ] +} \ No newline at end of file diff --git a/extensions/tsconfig.json b/extensions/tsconfig.json new file mode 100644 index 000000000..187f89a33 --- /dev/null +++ b/extensions/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "moduleResolution": "node", + "baseUrl": ".", + "paths": { + "../src/*": ["../src/*"] + }, + "typeRoots": ["../node_modules/@types"], + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": [ + "**/*.ts", + "**/*.js", + "*.d.ts" + ] +} \ No newline at end of file