Merge pull request #2722 from cdr/root-plugin
This commit is contained in:
commit
c2450d6bf3
|
@ -52,7 +52,6 @@
|
||||||
"@types/wtfnode": "^0.7.0",
|
"@types/wtfnode": "^0.7.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.7.0",
|
"@typescript-eslint/eslint-plugin": "^4.7.0",
|
||||||
"@typescript-eslint/parser": "^4.7.0",
|
"@typescript-eslint/parser": "^4.7.0",
|
||||||
"compression": "^1.7.4",
|
|
||||||
"doctoc": "^1.4.0",
|
"doctoc": "^1.4.0",
|
||||||
"eslint": "^7.7.0",
|
"eslint": "^7.7.0",
|
||||||
"eslint-config-prettier": "^6.0.0",
|
"eslint-config-prettier": "^6.0.0",
|
||||||
|
@ -77,6 +76,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coder/logger": "1.1.16",
|
"@coder/logger": "1.1.16",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
"compression": "^1.7.4",
|
||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"env-paths": "^2.2.0",
|
"env-paths": "^2.2.0",
|
||||||
"express": "^5.0.0-alpha.8",
|
"express": "^5.0.0-alpha.8",
|
||||||
|
|
|
@ -251,7 +251,7 @@ export class PluginAPI {
|
||||||
if (!p.routerPath) {
|
if (!p.routerPath) {
|
||||||
throw new Error("plugin missing router path")
|
throw new Error("plugin missing router path")
|
||||||
}
|
}
|
||||||
if (!p.routerPath.startsWith("/") || p.routerPath.length < 2) {
|
if (!p.routerPath.startsWith("/")) {
|
||||||
throw new Error(`plugin router path ${q(p.routerPath)}: invalid`)
|
throw new Error(`plugin router path ${q(p.routerPath)}: invalid`)
|
||||||
}
|
}
|
||||||
if (!p.homepageURL) {
|
if (!p.homepageURL) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import * as express from "express"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { HttpCode } from "../src/common/http"
|
import { HttpCode } from "../src/common/http"
|
||||||
|
import { AuthType } from "../src/node/cli"
|
||||||
import { codeServer, PluginAPI } from "../src/node/plugin"
|
import { codeServer, PluginAPI } from "../src/node/plugin"
|
||||||
import * as apps from "../src/node/routes/apps"
|
import * as apps from "../src/node/routes/apps"
|
||||||
import * as httpserver from "./httpserver"
|
import * as httpserver from "./httpserver"
|
||||||
|
@ -26,6 +27,28 @@ describe("plugin", () => {
|
||||||
|
|
||||||
const app = express.default()
|
const app = express.default()
|
||||||
const wsApp = express.default()
|
const wsApp = express.default()
|
||||||
|
|
||||||
|
const common: express.RequestHandler = (req, _, next) => {
|
||||||
|
// Routes might use these arguments.
|
||||||
|
req.args = {
|
||||||
|
_: [],
|
||||||
|
auth: AuthType.None,
|
||||||
|
host: "localhost",
|
||||||
|
port: 8080,
|
||||||
|
"proxy-domain": [],
|
||||||
|
config: "~/.config/code-server/config.yaml",
|
||||||
|
verbose: false,
|
||||||
|
usingEnvPassword: false,
|
||||||
|
usingEnvHashedPassword: false,
|
||||||
|
"extensions-dir": "",
|
||||||
|
"user-data-dir": "",
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
|
||||||
|
app.use(common)
|
||||||
|
wsApp.use(common)
|
||||||
|
|
||||||
papi.mount(app, wsApp)
|
papi.mount(app, wsApp)
|
||||||
app.use("/api/applications", apps.router(papi))
|
app.use("/api/applications", apps.router(papi))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue