Archived
1
0

routes/apps.ts: Implement /api/applications endpoint

This commit is contained in:
Anmol Sethi 2020-11-03 21:14:14 -05:00
parent afff86ae9c
commit e03bbe3149
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
2 changed files with 14 additions and 0 deletions

12
src/node/routes/apps.ts Normal file
View File

@ -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
}

View File

@ -23,6 +23,7 @@ import * as proxy from "./pathProxy"
import * as _static from "./static" import * as _static from "./static"
import * as update from "./update" import * as update from "./update"
import * as vscode from "./vscode" import * as vscode from "./vscode"
import * as apps from "./apps"
declare global { declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace // 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) const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH)
await papi.loadPlugins() await papi.loadPlugins()
papi.mount(app) papi.mount(app)
app.use("/api/applications", apps.router(papi))
app.use(() => { app.use(() => {
throw new HttpError("Not Found", HttpCode.NotFound) throw new HttpError("Not Found", HttpCode.NotFound)