This repository was archived by the owner on Jul 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 88 "bin" : {
99 "cortex" : " ./dist/src/command.js"
1010 },
11+ "main" : " dist/src/index.js" ,
12+ "types" : " dist/src/index.d.ts" ,
1113 "scripts" : {
1214 "dev" : " nest dev" ,
1315 "compile" : " npx ncc build ./dist/src/command.js -o command" ,
Original file line number Diff line number Diff line change 1+ import {
2+ CORTEX_JS_STOP_API_SERVER_URL ,
3+ defaultCortexJsHost ,
4+ defaultCortexJsPort ,
5+ } from '@/infrastructure/constants/cortex' ;
6+ import { getApp } from './app' ;
7+ import chalk from 'chalk' ;
8+
9+ /**
10+ * Start the API server
11+ */
12+ export async function start ( host ?: string , port ?: number ) {
13+ const app = await getApp ( ) ;
14+ // getting port from env
15+ const sHost = host || process . env . CORTEX_JS_HOST || defaultCortexJsHost ;
16+ const sPort = port || process . env . CORTEX_JS_PORT || defaultCortexJsPort ;
17+
18+ try {
19+ await app . listen ( sPort , sHost ) ;
20+ console . log ( chalk . blue ( `Started server at http://${ sHost } :${ sPort } ` ) ) ;
21+ console . log (
22+ chalk . blue ( `API Playground available at http://${ sHost } :${ sPort } /api` ) ,
23+ ) ;
24+ } catch {
25+ console . error ( `Failed to start server. Is port ${ port } in use?` ) ;
26+ }
27+ }
28+
29+ /**
30+ * Stop the API server
31+ * @returns
32+ */
33+ export async function stop ( ) {
34+ return fetch ( CORTEX_JS_STOP_API_SERVER_URL ( ) , {
35+ method : 'DELETE' ,
36+ } ) . catch ( ( ) => { } ) ;
37+ }
You can’t perform that action at this time.
0 commit comments