Skip to content

Commit cb15afa

Browse files
committed
chore(api): simplify vercel function config and move ping to TypeScript
Remove the explicit functions overrides from app/vercel.json so api routes rely on Vercel defaults, and replace api/ping.js with a typed api/ping.ts handler that supports both Request/Response and legacy (req, res) invocation while returning { ok: true, ping: true }. Made-with: Cursor
1 parent 16996a6 commit cb15afa

3 files changed

Lines changed: 42 additions & 14 deletions

File tree

app/api/ping.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/api/ping.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Zero-dependency health check.
3+
* GET /api/ping → { ok: true, ping: true }
4+
*
5+
* Supports both:
6+
* - Web API style (Request → Response)
7+
* - Legacy Node style (req, res)
8+
*/
9+
10+
type NodeRes = {
11+
setHeader(name: string, value: string): void;
12+
status(code: number): void;
13+
end(body?: string): void;
14+
};
15+
16+
function jsonResponse(body: object, status: number): Response {
17+
return new Response(JSON.stringify(body), {
18+
status,
19+
headers: { 'Content-Type': 'application/json' },
20+
});
21+
}
22+
23+
async function handler(
24+
request: Request,
25+
res?: NodeRes,
26+
): Promise<Response | void> {
27+
const body = { ok: true, ping: true };
28+
29+
if (res) {
30+
res.setHeader('Content-Type', 'application/json');
31+
res.status(200);
32+
res.end(JSON.stringify(body));
33+
return;
34+
}
35+
36+
return jsonResponse(body, 200);
37+
}
38+
39+
export default handler;
40+
export const GET = handler;
41+

app/vercel.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@
33
"buildCommand": "npm run db:migrate && npx expo export -p web && npx tsx scripts/set-webhook.ts",
44
"outputDirectory": "dist",
55
"framework": null,
6-
"installCommand": "npm install",
7-
"functions": {
8-
"api/ping.js": { "maxDuration": 10 },
9-
"api/telegram.ts": { "maxDuration": 60 }
10-
}
6+
"installCommand": "npm install"
117
}

0 commit comments

Comments
 (0)