Skip to content

Instantly share code, notes, and snippets.

@davidcsejtei
Created October 18, 2020 09:30
Show Gist options
  • Select an option

  • Save davidcsejtei/a8284e4dfa2e7722a40aaec10fac3bbf to your computer and use it in GitHub Desktop.

Select an option

Save davidcsejtei/a8284e4dfa2e7722a40aaec10fac3bbf to your computer and use it in GitHub Desktop.
Express application uses TypeORM
import "reflect-metadata";
import {createConnection, ConnectionOptions} from "typeorm";
import http from "http";
import express from 'express';
import config from "../ormconfig.json";
import GetAllUsers from "./controllers/GetAllUsers";
createConnection(config as ConnectionOptions).then(async connection => {
const app = express();
app.use(express.json());
const server = new http.Server(app);
server.listen(3001);
app.get('/users/all', GetAllUsers);
}).catch(error => {
console.log(error);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment