Skip to content

Instantly share code, notes, and snippets.

@andregardi
Last active February 8, 2019 10:26
Show Gist options
  • Save andregardi/e3499203050ba8a003a9c847e506be20 to your computer and use it in GitHub Desktop.
Save andregardi/e3499203050ba8a003a9c847e506be20 to your computer and use it in GitHub Desktop.
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