You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
1.1 KiB
23 lines
1.1 KiB
// Custom production server: wraps adapter-node's generated request handler in
|
|
// a plain http.Server so we can also intercept WebSocket upgrade requests,
|
|
// which SvelteKit itself has no hook for (see @webavatar/webavatar-core's
|
|
// server/ws-handler.ts).
|
|
//
|
|
// `.env` is not auto-loaded here (SvelteKit's own adapter-node doesn't in
|
|
// production either) — run with `node --env-file=.env server.js` locally, or
|
|
// provide OPENAI_API_KEY / REALTIME_TOKEN_SECRET via your deployment's real
|
|
// secret mechanism.
|
|
import { createServer } from 'node:http';
|
|
import { createRealtimeRuntime } from '@webavatar/webavatar-core/server';
|
|
import { handler } from './build/handler.js';
|
|
import { SESSION_PERSONA } from './build-server/project/persona.js';
|
|
import { toolRegistry } from './build-server/server/project/tools/index.js';
|
|
|
|
const runtime = createRealtimeRuntime({ persona: SESSION_PERSONA, toolRegistry, isDev: false });
|
|
const server = createServer(handler);
|
|
|
|
server.on('upgrade', runtime.handleUpgrade);
|
|
|
|
server.listen(runtime.config.port, () => {
|
|
console.log(`listening on port ${runtime.config.port}`);
|
|
});
|
|
|