Compare commits

..

4 Commits

2 changed files with 22 additions and 5 deletions

View File

@ -6,7 +6,9 @@
"author": "Philipp Dormann <philipp.dormann1@gmail.com>",
"license": "MIT",
"dependencies": {
"consola": "^2.15.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mysql": "^2.18.1",
"pg": "^8.5.1",
"typeorm": "^0.2.29"
@ -14,6 +16,7 @@
"devDependencies": {
"@types/dotenv-safe": "^8.1.1",
"@types/express": "^4.17.9",
"@types/jsonwebtoken": "^8.5.0",
"@types/node": "^14.14.9",
"dotenv-safe": "^8.2.0",
"nodemon": "^2.0.6",

View File

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