🦠 Added ignored folder back to git tracking
Signed-off-by: Rishi Ghan <rishi.ghan@gmail.com>
This commit is contained in:
29
src/server/index.ts
Normal file
29
src/server/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import express, { Request, Response, Router, Express } from "express";
|
||||
import bodyParser from "body-parser";
|
||||
import router from "./route";
|
||||
|
||||
// call express
|
||||
const app: Express = express(); // define our app using express
|
||||
|
||||
// configure app to use bodyParser for
|
||||
// Getting data from body of requests
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
const port: number = Number(process.env.PORT) || 8050; // set our port
|
||||
|
||||
// Send index.html on root request
|
||||
app.use(express.static("dist"));
|
||||
app.get("/", (req: Request, res: Response) => {
|
||||
console.log("sending index.html");
|
||||
res.sendFile("/dist/index.html");
|
||||
});
|
||||
|
||||
// REGISTER ROUTES
|
||||
// all of the routes will be prefixed with /api
|
||||
const routes: Router[] = Object.values(router);
|
||||
app.use("/api", routes);
|
||||
|
||||
app.listen(port);
|
||||
console.log(`App listening on ${port}`);
|
||||
Reference in New Issue
Block a user