Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import express from "express"
- import compression from "compression"
- import helmet from "helmet"
- import morgan from "morgan"
- // Add this
- import { createConnection } from "typeorm"
- import config from "./config"
- const app = express()
- // Add middlewares
- app.use(express.json())
- app.use(express.urlencoded({ extended: false }))
- app.use(helmet())
- app.use(compression())
- app.use(morgan("combined"));
- (async () => {
- try {
- const connection = await createConnection()
- console.log("Connection to Database established")
- } catch(err) {
- console.log("DB Connection Error: " + err)
- }
- app.post("*", (req, res) => {
- res.status(404).json({
- error: true,
- message: "Not found"
- });
- });
- const port = config.PORT || 3000;
- app.listen(port, () => {
- console.log(`App listening on port ${port}...`)
- })
- })();
- export default app
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement