From e03bbe31497b5581e578e03ebc5abc7a11b43580 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Tue, 3 Nov 2020 21:14:14 -0500 Subject: [PATCH] routes/apps.ts: Implement /api/applications endpoint --- src/node/routes/apps.ts | 12 ++++++++++++ src/node/routes/index.ts | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 src/node/routes/apps.ts diff --git a/src/node/routes/apps.ts b/src/node/routes/apps.ts new file mode 100644 index 00000000..970bd3cb --- /dev/null +++ b/src/node/routes/apps.ts @@ -0,0 +1,12 @@ +import * as express from "express" +import { PluginAPI } from "../plugin" + +export function router(papi: PluginAPI): express.Router { + const router = express.Router() + + router.get("/", async (req, res) => { + res.json(await papi.applications()) + }) + + return router +} diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 5824475d..a39b2a6a 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -23,6 +23,7 @@ import * as proxy from "./pathProxy" import * as _static from "./static" import * as update from "./update" import * as vscode from "./vscode" +import * as apps from "./apps" declare global { // eslint-disable-next-line @typescript-eslint/no-namespace @@ -118,6 +119,7 @@ export const register = async ( const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH) await papi.loadPlugins() papi.mount(app) + app.use("/api/applications", apps.router(papi)) app.use(() => { throw new HttpError("Not Found", HttpCode.NotFound)