Files
code-center/convex/http.ts
2026-01-26 02:44:17 +08:00

39 lines
1.3 KiB
TypeScript

import { httpRouter } from "convex/server";
import { httpAction } from "./_generated/server";
const http = httpRouter();
http.route({
path: "/auth",
method: "POST",
handler: httpAction(async (ctx, request) => {
// 处理请求并返回响应
return new Response(JSON.stringify({ message: "Hello from custom endpoint!" }), {
status: 200,
headers: { "Content-Type": "application/json" },
});
}),
})
// https://api-convex.kevisual.cn/root/convex/jwks.json
http.route({
path: '/root/convex/jwks.json',
method: 'GET',
handler: httpAction(async (ctx, request) => {
// 返回 JWKS 数据
const jwks = {
"keys": [
{
"kty": "RSA",
"n": "km4cjJJOMFkl2G5qWMuFmWwF7rmeqRYzYdR8SddKeeMW0e9yIf5pv2Mfwv0aMJUpb-_j3j9M7whx_SEGc_2jx1vxCu1AlYURhnnLTWdsR-ZRPr2LK9UstMrgpWV425R2RliqXTDTYlSxUUlD9nPue_tqbfwN2aM9MCarm67xK_ZCcKRlW9o9L2-9UMfzRA7uiy4VQtOemP0PTXp-E9RxNiMPOQXIRls9wTW_EkDT3dGy7JCZhj7_qib3T8k9m84SwU7wI2R_3IH4DcHSMAn1BRRMXZ1_wPhbP39laNtdJgbDjGCqUccGhLUaoo2WGkZ52eb7NPqamp0K1Dh2jwTIJQ",
"e": "AQAB",
"kid": "kid-key-1"
}
]
};
return new Response(JSON.stringify(jwks), {
status: 200,
headers: { "Content-Type": "application/json" },
});
}),
})
export default http;