Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f751b8d

Browse files
Convert routes to Express
1 parent aec6809 commit f751b8d

File tree

20 files changed

+1015
-1507
lines changed

20 files changed

+1015
-1507
lines changed

‎.eslintrc.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ rules:
3131
import/order:
3232
[error, { alphabetize: { order: "asc" }, groups: [["builtin", "external", "internal"], "parent", "sibling"] }]
3333
no-async-promise-executor: off
34+
# This isn't a real module, just types, which apparently doesn't resolve.
35+
import/no-unresolved: [error, { ignore: ["express-serve-static-core"] }]
3436

3537
settings:
3638
# Does not work with CommonJS unfortunately.

‎ci/dev/vscode.patch‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ index 0000000000000000000000000000000000000000..56331ff1fc32bbd82e769aaecb551e42
13181318
+require('../../bootstrap-amd').load('vs/server/entry');
13191319
diff --git a/src/vs/server/ipc.d.ts b/src/vs/server/ipc.d.ts
13201320
new file mode 100644
1321-
index 0000000000000000000000000000000000000000..33b28cf2d53746ee9c50c056ac2e087dcee0a4e2
1321+
index 0000000000000000000000000000000000000000..6ce56bec114a6d8daf5dd3ded945ea78fc72a5c6
13221322
--- /dev/null
13231323
+++ b/src/vs/server/ipc.d.ts
13241324
@@ -0,0 +1,131 @@
@@ -1336,7 +1336,7 @@ index 0000000000000000000000000000000000000000..33b28cf2d53746ee9c50c056ac2e087d
13361336
+ options: VscodeOptions;
13371337
+}
13381338
+
1339-
+export type Query = { [key: string]: string | string[] | undefined };
1339+
+export type Query = { [key: string]: string | string[] | undefined | Query | Query[] };
13401340
+
13411341
+export interface SocketMessage {
13421342
+ type: 'socket';

‎package.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
},
3131
"main": "out/node/entry.js",
3232
"devDependencies": {
33+
"@types/body-parser": "^1.19.0",
34+
"@types/cookie-parser": "^1.4.2",
3335
"@types/express": "^4.17.8",
3436
"@types/fs-extra": "^8.0.1",
3537
"@types/http-proxy": "^1.17.4",
@@ -67,6 +69,8 @@
6769
},
6870
"dependencies": {
6971
"@coder/logger": "1.1.16",
72+
"body-parser": "^1.19.0",
73+
"cookie-parser": "^1.4.5",
7074
"env-paths": "^2.2.0",
7175
"express": "^4.17.1",
7276
"fs-extra": "^9.0.1",
@@ -75,6 +79,7 @@
7579
"js-yaml": "^3.13.1",
7680
"limiter": "^1.1.5",
7781
"pem": "^1.14.2",
82+
"qs": "6.7.0",
7883
"rotating-file-stream": "^2.1.1",
7984
"safe-buffer": "^5.1.1",
8085
"safe-compare": "^1.1.4",

‎src/common/http.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export enum HttpCode {
99
}
1010

1111
export class HttpError extends Error {
12-
public constructor(message: string, public readonly code: number, public readonly details?: object) {
12+
public constructor(message: string, public readonly status: number, public readonly details?: object) {
1313
super(message)
1414
this.name = this.constructor.name
1515
}

‎src/node/app.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { promises as fs } from "fs"
44
import http from "http"
55
import * as httpolyglot from "httpolyglot"
66
import { DefaultedArgs } from "./cli"
7+
import { handleUpgrade } from "./http"
78

89
/**
910
* Create an Express app and an HTTP/S server to serve it.
@@ -38,6 +39,8 @@ export const createApp = async (args: DefaultedArgs): Promise<[Express, http.Ser
3839
}
3940
})
4041

42+
handleUpgrade(app, server)
43+
4144
return [app, server]
4245
}
4346

‎src/node/entry.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from "./cli"
1919
import { coderCloudBind } from "./coder-cloud"
2020
import { commit, version } from "./constants"
21-
import { loadPlugins } from "./plugin"
21+
import { register } from "./routes"
2222
import { humanPath, open } from "./util"
2323
import { ipcMain, WrapperProcess } from "./wrapper"
2424

@@ -111,15 +111,14 @@ const main = async (args: DefaultedArgs): Promise<void> => {
111111
if (args.auth === AuthType.Password && !args.password) {
112112
throw new Error("Please pass in a password via the config file or $PASSWORD")
113113
}
114+
114115
ipcMain.onDispose(() => {
115116
// TODO: register disposables
116117
})
117118

118119
const [app, server] = await createApp(args)
119120
const serverAddress = ensureAddress(server)
120-
121-
// TODO: register routes
122-
await loadPlugins(app, args)
121+
await register(app, server, args)
123122

124123
logger.info(`Using config file ${humanPath(args.config)}`)
125124
logger.info(`HTTP server listening on ${serverAddress} ${args.link ? "(randomized by --link)" : ""}`)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /