diff --git a/packages/core/src/session/index.ts b/packages/core/src/session/index.ts index d9add3cc..43ec3a33 100644 --- a/packages/core/src/session/index.ts +++ b/packages/core/src/session/index.ts @@ -10,9 +10,9 @@ import { AudioCodecName, RetryOptions, SessionInfo, - type SessionInfo as SessionInfoType, - type Session as SessionInterface, type Config as SessionConfig, + type Session as SessionInterface, + type SessionInfo as SessionInfoType, } from "./types.js"; import { Actor } from "../actor.js"; import { Database } from "../drizzle/index.js"; @@ -93,16 +93,16 @@ export namespace Session { export function serialize( input: typeof sessionTable.$inferSelect, - ): z.infer { + ): z.infer { return { id: input.id, - room: input.room || undefined, + // room: input.room || undefined, + machine: input.machine, + relayUrl: input.relayUrl, retry: input.retry || undefined, queue: input.queue || undefined, - machine: input.machine || undefined, description: input.description || undefined, maxDuration: input.maxDuration || undefined, - relayUrl: input.relayUrl || undefined, resolution: input.resolution || undefined, framerate: input.framerate || undefined, gpuVendor: input.gpuVendor || undefined, diff --git a/packages/core/src/session/session.sql.ts b/packages/core/src/session/session.sql.ts index 68956232..be2c7ac6 100644 --- a/packages/core/src/session/session.sql.ts +++ b/packages/core/src/session/session.sql.ts @@ -33,14 +33,17 @@ export const sessionTable = pgTable("sessions", { .notNull(), retry: jsonb("retry").$type(), queue: jsonb("queue").$type(), - machine: varchar("machine", { length: 200 }).$type(), + machine: varchar("machine", { length: 200 }) + .$type() + .notNull() + .default("ns3-micro"), maxDuration: integer("max_duration"), - relayUrl: varchar("relay_url", { length: 500 }), + relayUrl: varchar("relay_url", { length: 500 }).notNull(), resolution: varchar("resolution", { length: 20, }).$type(), framerate: integer("framerate"), - room: varchar("room", { length: 255 }), + // room: varchar("room", { length: 255 }), gpuVendor: varchar("gpu_vendor", { length: 100 }), gpuName: varchar("gpu_name", { length: 255 }), gpuIndex: integer("gpu_index"), diff --git a/packages/core/src/session/types.ts b/packages/core/src/session/types.ts index 46de8c46..3305fdd6 100644 --- a/packages/core/src/session/types.ts +++ b/packages/core/src/session/types.ts @@ -123,20 +123,26 @@ export const SessionInfo = z example: Examples.Session.queue, }), /** Machine preset for the session */ - machine: MachinePresetName.optional().meta({ - description: "Machine preset for the session", - example: Examples.Session.machine, - }), + machine: MachinePresetName.optional() + .meta({ + description: "Machine preset for the session", + example: Examples.Session.machine, + }) + .default("ns3-micro"), /** Maximum duration in seconds the session can run */ maxDuration: z.number().optional().meta({ description: "Maximum duration in seconds the session can run", example: Examples.Session.maxDuration, }), /** Nestri relay URL for streaming and signaling */ - relayUrl: z.url().optional().meta({ - description: "Nestri relay URL for streaming and signaling", - example: Examples.Session.relayUrl, - }), + relayUrl: z + .url() + .optional() + .meta({ + description: "Nestri relay URL for streaming and signaling", + example: Examples.Session.relayUrl, + }) + .default("https://relay.nestri.io"), /** Display or stream resolution in 'WxH' format */ resolution: ScreenResolutionPresetName.optional().meta({ description: "Display or stream resolution in 'WxH' format", @@ -148,10 +154,10 @@ export const SessionInfo = z example: Examples.Session.framerate, }), /** Room name or identifier for multiplayer sessions */ - room: z.string().optional().meta({ - description: "Room name or identifier for multiplayer sessions", - example: Examples.Session.room, - }), + // room: z.string().optional().meta({ + // description: "Room name or identifier for multiplayer sessions", + // example: Examples.Session.room, + // }), /** Preferred GPU vendor */ gpuVendor: z.string().optional().meta({ description: "Preferred GPU vendor", diff --git a/packages/function/src/api/index.ts b/packages/function/src/api/index.ts index 8de33ca7..4c60549f 100644 --- a/packages/function/src/api/index.ts +++ b/packages/function/src/api/index.ts @@ -3,6 +3,7 @@ import { Hono } from "hono"; import { cors } from "hono/cors"; import { auth } from "./utils/auth"; import { Log } from "@nestri/core/utils/log"; +import { SessionApi } from "./routes/session.js"; import { HTTPException } from "hono/http-exception"; import { VisibleError, ErrorCodes } from "@nestri/core/error"; import { openAPIRouteHandler, validator } from "hono-openapi"; @@ -38,6 +39,7 @@ export const routes = app .get("/", async (c) => { return c.text("ok"); }) + .route("/session", SessionApi.route) .onError((error, c) => { // Handle our custom VisibleError if (error instanceof VisibleError) { diff --git a/packages/function/src/api/routes/session.ts b/packages/function/src/api/routes/session.ts index 4068d60d..587c9bd2 100644 --- a/packages/function/src/api/routes/session.ts +++ b/packages/function/src/api/routes/session.ts @@ -4,7 +4,7 @@ import { ErrorResponses } from "../utils/error.js"; import { Session } from "@nestri/core/session/index"; import { describeRoute, resolver, validator } from "hono-openapi"; -export namespace SessionRoute { +export namespace SessionApi { export const route = new Hono() .use(notPublic) .get(