parent
a3a809bb40
commit
f58a715c45
|
@ -1,5 +1,8 @@
|
|||
import { createConnection } from "typeorm";
|
||||
|
||||
/**
|
||||
* Loader for the database that creates the database connection and initializes the database tabels.
|
||||
*/
|
||||
export default async () => {
|
||||
const connection = await createConnection();
|
||||
connection.synchronize();
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
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) => {
|
||||
app.enable('trust proxy');
|
||||
return app;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { Application } from "express";
|
||||
import databaseLoader from "./database";
|
||||
import expressLoader from "./express";
|
||||
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) => {
|
||||
await databaseLoader();
|
||||
await openapiLoader(app);
|
||||
|
|
|
@ -4,11 +4,16 @@ import { getMetadataArgsStorage } from "routing-controllers";
|
|||
import { routingControllersToSpec } from "routing-controllers-openapi";
|
||||
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) => {
|
||||
const storage = getMetadataArgsStorage();
|
||||
const schemas = validationMetadatasToSchemas({
|
||||
refPointerPrefix: "#/components/schemas/",
|
||||
});
|
||||
|
||||
//Spec creation based on the previously created schemas
|
||||
const spec = routingControllersToSpec(
|
||||
storage,
|
||||
{
|
||||
|
@ -32,6 +37,8 @@ export default async (app: Application) => {
|
|||
},
|
||||
}
|
||||
);
|
||||
|
||||
//Options for swaggerUiExpress
|
||||
const options = {
|
||||
explorer: true,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue