diff --git a/src/node/plugin.ts b/src/node/plugin.ts index cf06d3d70..702201039 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -5,6 +5,7 @@ import * as path from "path" import * as semver from "semver" import * as pluginapi from "../../typings/pluginapi" import { version } from "./constants" +import { replaceTemplates } from "./http" import { proxy } from "./proxy" import * as util from "./util" import { Router as WsRouter, WebsocketRouter, wss } from "./wsRouter" @@ -23,6 +24,7 @@ require("module")._load = function (request: string, parent: object, isMain: boo field, Level, proxy, + replaceTemplates, WsRouter, wss, } diff --git a/typings/pluginapi.d.ts b/typings/pluginapi.d.ts index b0f6bd02d..fbac3af9b 100644 --- a/typings/pluginapi.d.ts +++ b/typings/pluginapi.d.ts @@ -123,8 +123,20 @@ export { express } */ export { field, Level, Logger } +/** + * code-server's proxy server. + */ export const proxy: ProxyServer +/** + * Replace variables in HTML: TO, BASE, CS_STATIC_BASE, and OPTIONS. + */ +export function replaceTemplates( + req: express.Request, + content: string, + extraOpts?: Omit, +): string + /** * Your plugin module must have a top level export "plugin" that implements this interface. *