MCPcopy
hub / github.com/coder/code-server / createApp

Function createApp

src/node/app.ts:69–99  ·  view source on GitHub ↗
(args: DefaultedArgs)

Source from the content-addressed store, hash-verified

67 * Create an Express app and an HTTP/S server to serve it.
68 */
69export const createApp = async (args: DefaultedArgs): Promise<App> => {
70 const router = express()
71 router.use(compression())
72
73 const server = args.cert
74 ? httpolyglot.createServer(
75 {
76 cert: args.cert && (await fs.readFile(args.cert.value)),
77 key: args["cert-key"] && (await fs.readFile(args["cert-key"])),
78 },
79 router,
80 )
81 : http.createServer(router)
82
83 const disposeServer = disposer(server)
84
85 await listen(server, args)
86
87 const wsRouter = express()
88 handleUpgrade(wsRouter, server)
89
90 const editorSessionManager = new EditorSessionManager()
91 const editorSessionManagerServer = await makeEditorSessionManagerServer(args["session-socket"], editorSessionManager)
92 const disposeEditorSessionManagerServer = disposer(editorSessionManagerServer)
93
94 const dispose = async () => {
95 await Promise.all([disposeServer(), disposeEditorSessionManagerServer()])
96 }
97
98 return { router, wsRouter, server, dispose, editorSessionManagerServer }
99}
100
101/**
102 * Get the address of a server as a string (protocol *is* included) while

Callers 3

app.test.tsFile · 0.90
masterBallFunction · 0.90
runCodeServerFunction · 0.90

Calls 4

disposerFunction · 0.90
handleUpgradeFunction · 0.90
listenFunction · 0.85

Tested by 1

masterBallFunction · 0.72