Last active
February 8, 2019 10:26
-
-
Save andregardi/e3499203050ba8a003a9c847e506be20 to your computer and use it in GitHub Desktop.
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
import "reflect-metadata"; | |
import { createConnection } from "typeorm"; | |
import * as express from "express"; | |
import * as bodyParser from "body-parser"; | |
import * as helmet from "helmet"; | |
import * as cors from "cors"; | |
import routes from "./routes"; | |
//Connects to the Database -> then starts the express | |
createConnection() | |
.then(async connection => { | |
// Create a new express application instance | |
const app = express(); | |
// Call midlewares | |
app.use(cors()); | |
app.use(helmet()); | |
app.use(bodyParser.json()); | |
//Set all routes from routes folder | |
app.use("/", routes); | |
app.listen(3000, () => { | |
console.log("Server started on port 3000!"); | |
}); | |
}) | |
.catch(error => console.log(error)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment