Skip to content

Commit

Permalink
express app and plugin routes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhayrp2000 committed Jul 14, 2023
1 parent ed6b37e commit 56cbb5c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//ENV
import { Logger } from "./middleware/log/logger";
import * as dotenv from "dotenv";
dotenv.config({ path: __dirname + "/.env" });
import { prismaWrapper } from "./utils/prisma";
import express from "express";
import v1Routes from "./routes/index";
import { logRequest } from "./middleware/log/http-requests-logger";

export const logger = new Logger();

const start = async () => {
["POSTGRES_URL"].map((envVar) => {
if (!process.env[envVar]) {
throw new Error(`Missing environment variable ${envVar}`);
}
});

//* Connect to the database
await prismaWrapper.connect();

const port = 3000;

const app = express();
app.use(express.json());
app.use(logRequest);
app.use("/v1", v1Routes);
app.listen(port, () => {
console.log("Listening on port " + port);
});
};

start();

0 comments on commit 56cbb5c

Please sign in to comment.