feat: Add more API endpoints (#150)

This commit is contained in:
Wanjohi
2025-01-05 01:06:34 +03:00
committed by GitHub
parent dede878c3c
commit b47448255f
18 changed files with 1271 additions and 269 deletions

View File

@@ -50,18 +50,19 @@ export module AuthApi {
const env = c.env as any
const room = env.room as Party.Room
const connection = room.getConnection(param.connection)
if (!connection) {
return c.json({ error: "This device does not exist." }, 404);
}
const authParams = getUrlParams(new URL(c.req.url))
const res = paramsObj.safeParse(authParams)
if (res.error) {
return c.json({ error: "Expected url params are missing" })
}
// const connection = room.getConnection(param.connection)
// if (!connection) {
// return c.json({ error: "This device does not exist." }, 404);
// }
connection.send(JSON.stringify({ ...authParams, type: "auth" }))
// const authParams = getUrlParams(new URL(c.req.url))
// const res = paramsObj.safeParse(authParams)
// if (res.error) {
// return c.json({ error: "Expected url params are missing" })
// }
// connection.send(JSON.stringify({ ...authParams, type: "auth" }))
// FIXME:We just assume the authentication was successful, might wanna do some questioning in the future
return c.text("Device authenticated successfully")