Added "/api" route prefix

ref #4 #5
This commit is contained in:
Nicolai Ort 2020-11-27 19:32:29 +01:00
parent b382f0689b
commit 4e5e08483d
2 changed files with 7 additions and 3 deletions

View File

@ -10,6 +10,8 @@ const PORT = process.env.APP_PORT || 4010;
const app = createExpressServer({
controllers: [__dirname + "/controllers/*.ts"],
development: process.env.NODE_ENV === "production",
routePrefix: "/api",
controllers: [__dirname + "/controllers/*.ts"],
});
async function main() {

View File

@ -11,7 +11,9 @@ export default async (app: Application) => {
});
const spec = routingControllersToSpec(
storage,
{},
{
routePrefix: "/api"
},
{
components: {
schemas,
@ -27,11 +29,11 @@ export default async (app: Application) => {
explorer: true,
};
app.use(
"/docs",
"/api/docs",
swaggerUiExpress.serve,
swaggerUiExpress.setup(spec, options)
);
app.get(["/openapi.json", "/swagger.json"], (req, res) => {
app.get(["/api/openapi.json", "/api/swagger.json"], (req, res) => {
res.json(spec);
});
return app;