wynn/ts/src/apiserver/contract.ts
a 79cea96292
Some checks failed
commit-tag / commit-tag-image (push) Failing after 16s
its a matrix now
2025-03-02 17:55:01 -06:00

51 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
})