parent
a3a809bb40
commit
f58a715c45
@ -1,5 +1,8 @@
|
|||||||
import { createConnection } from "typeorm";
|
import { createConnection } from "typeorm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loader for the database that creates the database connection and initializes the database tabels.
|
||||||
|
*/
|
||||||
export default async () => {
|
export default async () => {
|
||||||
const connection = await createConnection();
|
const connection = await createConnection();
|
||||||
connection.synchronize();
|
connection.synchronize();
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { Application } from "express";
|
import { Application } from "express";
|
||||||
import bodyParser from 'body-parser';
|
|
||||||
import cors from 'cors';
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loader for express related configurations.
|
||||||
|
* Currently only enables the proxy trust.
|
||||||
|
*/
|
||||||
export default async (app: Application) => {
|
export default async (app: Application) => {
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
return app;
|
return app;
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
|
import { Application } from "express";
|
||||||
|
import databaseLoader from "./database";
|
||||||
import expressLoader from "./express";
|
import expressLoader from "./express";
|
||||||
import openapiLoader from "./openapi";
|
import openapiLoader from "./openapi";
|
||||||
import databaseLoader from "./database";
|
|
||||||
import { Application } from "express";
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index Loader that executes the other loaders in the right order.
|
||||||
|
*/
|
||||||
export default async (app: Application) => {
|
export default async (app: Application) => {
|
||||||
await databaseLoader();
|
await databaseLoader();
|
||||||
await openapiLoader(app);
|
await openapiLoader(app);
|
||||||
|
@ -4,11 +4,16 @@ import { getMetadataArgsStorage } from "routing-controllers";
|
|||||||
import { routingControllersToSpec } from "routing-controllers-openapi";
|
import { routingControllersToSpec } from "routing-controllers-openapi";
|
||||||
import * as swaggerUiExpress from "swagger-ui-express";
|
import * as swaggerUiExpress from "swagger-ui-express";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loader for everything openapi related - from creating the schema to serving it via a static route.
|
||||||
|
*/
|
||||||
export default async (app: Application) => {
|
export default async (app: Application) => {
|
||||||
const storage = getMetadataArgsStorage();
|
const storage = getMetadataArgsStorage();
|
||||||
const schemas = validationMetadatasToSchemas({
|
const schemas = validationMetadatasToSchemas({
|
||||||
refPointerPrefix: "#/components/schemas/",
|
refPointerPrefix: "#/components/schemas/",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Spec creation based on the previously created schemas
|
||||||
const spec = routingControllersToSpec(
|
const spec = routingControllersToSpec(
|
||||||
storage,
|
storage,
|
||||||
{
|
{
|
||||||
@ -32,6 +37,8 @@ export default async (app: Application) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Options for swaggerUiExpress
|
||||||
const options = {
|
const options = {
|
||||||
explorer: true,
|
explorer: true,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user