Newer
Older
ServerGenerator / src / server.ts
import express from "express";
import { graphMiddleware } from "./ExampleOutput/Middleware";
import {join} from "path";

const port = 8080;
const webRoot = "/";

const INDEX_ROUTE = "index";

const app = express();
app.disable("x-powered-by");

app.use(graphMiddleware({fileName: join(__dirname, "..", "src", "ExampleOutput", "graph.json")}))

import * as swaggerUi from "swagger-ui-express";
import * as swaggerDocument from "./ExampleOutput/openapi.json";

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.get(`${webRoot}${INDEX_ROUTE}`, (req, res) => {
    res.send("Hello there :-)");
});

// should be one of the last routes:
// app.use(express.static(join(__dirname, "..", "..", "client", "static")));

app.listen(port, () => console.log(`ServerGenerator running on port ${port}...`));