-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed6b37e
commit 56cbb5c
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |