wynn/ts/src/apiserver/contract.ts
a eed7d950ea
Some checks failed
commit-tag / commit-tag-image (map[context:./migrations file:./migrations/Dockerfile name:migrations]) (push) Has been cancelled
commit-tag / commit-tag-image (map[context:./ts file:./ts/Dockerfile name:ts]) (push) Has been cancelled
noot
2025-03-17 16:27:25 -05:00

50 lines
1.0 KiB
TypeScript

import { initContract } from "@ts-rest/core/src";
import { type } from "arktype";
const con = initContract();
const ingameauth = con.router({
challenge: {
description: "generate a challenge for the client to solve",
method: "GET",
path: "/challenge",
responses: {
200: type({
challenge: "string.uuid",
}),
},
query: type({
uuid: "string.uuid",
}),
},
solve: {
description: "attempt to solve the challenge and get the token for the challenge",
method: "POST",
path: "/solve",
body: type({
challenge: "string.uuid",
uuid: "string.uuid",
}),
responses: {
200: type({
success: "true",
challenge: "string.uuid",
uuid: "string.uuid",
}),
401: type({
success: "false",
reason: "string",
}),
},
}
}, {pathPrefix: "/ingame"})
export const api = con.router({
"ingameauth": ingameauth,
}, {pathPrefix: "/api/v1"})
export const contract = con.router({
api: api
})