51 lines
1.0 KiB
TypeScript
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
|
|
})
|
|
|