MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / runBaseServer

Function runBaseServer

packages/baseai/src/dev/index.ts:18–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16import { registerV1PipesRun } from './routes/v1/pipes/run';
17
18export async function runBaseServer() {
19 const app = new Hono();
20
21 app.use(trimTrailingSlash());
22 app.use('*', customCors);
23 app.use(prettyJSON());
24 app.use(poweredBy());
25 app.use(preFlight());
26 app.onError((err, c) => {
27 return handleError(err, c as unknown as Context<HonoEnv, any, {}>);
28 });
29
30 // Routes.
31 registerRoot(app);
32 registerV1PipesRun(app);
33
34 const port = 9000;
35
36 try {
37 p.intro(heading({ text: 'DEV', sub: 'BaseAI dev server' }));
38
39 const server = serve({
40 fetch: app.fetch,
41 port
42 });
43
44 server.on('error', (e: NodeJS.ErrnoException) => {
45 if (e.code === 'EADDRINUSE') {
46 p.log.error(
47 color.red(`Error: Port ${port} is already in use.`)
48 );
49 p.log.info(
50 `Please close the other application using 9000 port. And try again.`
51 );
52
53 process.exit(1);
54 } else {
55 console.error('Unexpected server error:', e);
56 process.exit(1);
57 }
58 });
59
60 server.on('listening', () => {
61 outro(
62 `BaseAI server running on: ${color.green(`http://localhost:${port}`)}`
63 );
64 console.log(
65 `When needed you can press ${color.cyan('Ctrl + C')} to shut down.`
66 );
67 });
68
69 // Add immediate shutdown handler using Clack
70 process.on('SIGINT', () => {
71 const spinner = p.spinner();
72 spinner.start('Shutting down server');
73
74 server.close(() => {
75 spinner.stop('Shutting down the server …');

Callers 1

index.tsFile · 0.90

Calls 8

poweredByFunction · 0.90
preFlightFunction · 0.90
handleErrorFunction · 0.90
registerRootFunction · 0.90
registerV1PipesRunFunction · 0.90
headingFunction · 0.90
logMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected