sample implementation of db connection

ref #1 #2
This commit is contained in:
2020-11-24 19:28:57 +01:00
parent 79f883fc31
commit 0d870be23c
3 changed files with 25 additions and 10 deletions

View File

@@ -1,9 +1,18 @@
import * as dotenvSafe from 'dotenv-safe';
dotenvSafe.config();
import express from 'express';
const app = express();
const PORT = 4010;
app.get('/', (req, res) => res.send('Express + TypeScript Server'));
app.listen(PORT, () => {
console.log(`⚡️[server]: Server is running at http://localhost:${PORT}`);
});
import { createConnection } from 'typeorm';
dotenvSafe.config();
createConnection()
.then((connection) => {
const app = express();
const PORT = process.env.APP_PORT || 4010;
app.get('/', (req, res) => res.send('Express + TypeScript Server'));
app.listen(PORT, () => {
console.log(`⚡️[server]: Server is running at http://localhost:${PORT}`);
});
})
.catch((err) => {
console.log(err);
});