MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix types

+29 -18
+5 -2
examples/spa/server.js examples/spa/server.ts
··· 3 3 import { createRouter, addRoute, findRoute } from '../rou3'; 4 4 5 5 const router = createRouter(); 6 - 7 6 const validPaths = new Set(); 8 7 const invalidPaths = new Set(); 9 8 ··· 24 23 ['.woff', 'font/woff'], 25 24 ['.woff2', 'font/woff2'] 26 25 ]); 26 + 27 + type Context = HttpContext & { params: Record<string, string> }; 28 + type Handler = (ctx: Context) => void | Promise<void>; 29 + declare function addRoute(router: unknown, method: string, path: string, handler: Handler): void; 27 30 28 31 addRoute(router, 'GET', '/api/version', async c => c.res.json({ version: Ant.version })); 29 32 ··· 54 57 } 55 58 }); 56 59 57 - async function handleRequest(c) { 60 + async function handleRequest(c: Context) { 58 61 console.log('request:', c.req.method, c.req.uri); 59 62 const result = findRoute(router, c.req.method, c.req.uri); 60 63
+14 -12
src/types/ant.d.ts
··· 51 51 } 52 52 53 53 interface HttpContext { 54 - request: { 54 + req: { 55 55 method: string; 56 - url: string; 57 - path: string; 56 + uri: string; 58 57 query: string; 59 58 body: string; 60 - headers: Record<string, string>; 59 + header(name: string): string | undefined; 61 60 }; 62 - response: { 63 - status(code: number): HttpContext['response']; 64 - header(name: string, value: string): HttpContext['response']; 65 - send(body: string): void; 66 - json(data: unknown): void; 61 + res: { 62 + header(name: string, value: string): void; 63 + status(code: number): void; 64 + body(body: string, status?: number, contentType?: string): void; 65 + html(body: string, status?: number): void; 66 + json(data: unknown, status?: number): void; 67 + notFound(): void; 67 68 redirect(url: string, status?: number): void; 68 69 }; 69 - store: Record<string, unknown>; 70 + set(key: string, value: unknown): void; 71 + get(key: string): unknown; 70 72 } 71 73 72 74 interface AntStatic { ··· 81 83 alloc(): AntAllocResult; 82 84 stats(): AntStatsResult; 83 85 84 - signal(signum: number, handler: (signum: number) => void): void; 85 86 sleep(seconds: number): void; 86 87 msleep(milliseconds: number): void; 87 88 usleep(microseconds: number): void; 88 89 89 - serve(port: number, handler?: (ctx: HttpContext) => void | Promise<void>): number; 90 + signal(signum: number, handler: (signum: number) => void): void; 91 + serve<T extends HttpContext = HttpContext>(port: number, handler?: (ctx: T) => void | Promise<void>): number; 90 92 } 91 93 92 94 declare const Ant: AntStatic;
+9
src/types/import.d.ts
··· 1 + interface ImportMeta { 2 + url: string; 3 + filename: boolean; 4 + dirname: string; 5 + main: boolean; 6 + resolve(specifier: string): string; 7 + 8 + readonly env: { [key: string]: string }; 9 + }
-3
src/types/snapshot.d.ts
··· 1 - interface ImportMeta { 2 - readonly env: { [key: string]: string }; 3 - }
+1 -1
tsconfig.json
··· 2 2 "compilerOptions": { 3 3 "noEmit": true, 4 4 "strict": true, 5 - "noUnusedLocals": false, 5 + "noImplicitAny": true, 6 6 7 7 "target": "ES2024", 8 8 "module": "ESNext",