upd
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import authMiddleware from "../middlewares/auth";
|
||||
import createSession from "../services/sessions/create";
|
||||
import getSessions from "../services/sessions/get";
|
||||
import updateSession from "../services/sessions/update";
|
||||
|
||||
const sessionsController = new Elysia({ prefix: "/sessions" })
|
||||
.use(authMiddleware)
|
||||
.get(
|
||||
"/",
|
||||
async ({ auth, query }) => {
|
||||
return await getSessions(auth, query);
|
||||
},
|
||||
{
|
||||
query: t.Object({ limit: t.Optional(t.Number()) }),
|
||||
}
|
||||
)
|
||||
.post(
|
||||
"/",
|
||||
async ({ body, auth }) => {
|
||||
return await createSession(auth, body);
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
appId: t.String(),
|
||||
serverId: t.String(),
|
||||
clientId: t.String(),
|
||||
}),
|
||||
}
|
||||
)
|
||||
.put(
|
||||
"/:id",
|
||||
async ({ params, body }) => {
|
||||
return await updateSession(
|
||||
params.id,
|
||||
body.status as
|
||||
| "starting"
|
||||
| "started"
|
||||
| "restarting"
|
||||
| "ending"
|
||||
| "ended"
|
||||
);
|
||||
},
|
||||
{
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
status: t.Union([
|
||||
t.Literal("starting"),
|
||||
t.Literal("started"),
|
||||
t.Literal("restarting"),
|
||||
t.Literal("ending"),
|
||||
t.Literal("ended"),
|
||||
t.Literal("null"),
|
||||
t.Literal("undefined"),
|
||||
]),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
export default sessionsController;
|
||||
Reference in New Issue
Block a user