sample route actions for jwt + consola demo
This commit is contained in:
parent
6b46a0a69e
commit
8140d76240
24
src/app.ts
24
src/app.ts
|
@ -1,18 +1,32 @@
|
||||||
import * as dotenvSafe from 'dotenv-safe';
|
import * as dotenvSafe from 'dotenv-safe';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
import consola from 'consola';
|
||||||
|
import * as jwt from 'jsonwebtoken';
|
||||||
import { createConnection } from 'typeorm';
|
import { createConnection } from 'typeorm';
|
||||||
|
|
||||||
dotenvSafe.config();
|
dotenvSafe.config();
|
||||||
|
const app = express();
|
||||||
|
const PORT = process.env.APP_PORT || 4010;
|
||||||
|
|
||||||
createConnection()
|
createConnection()
|
||||||
.then((connection) => {
|
.then((connection) => {
|
||||||
const app = express();
|
app.get('/', (req, res) => {
|
||||||
const PORT = process.env.APP_PORT || 4010;
|
const encoded = jwt.sign({ key: 'value' }, 'secret');
|
||||||
app.get('/', (req, res) => res.send('Express + TypeScript Server'));
|
consola.info(encoded);
|
||||||
|
return res.send('Express + TypeScript Server');
|
||||||
|
});
|
||||||
app.listen(PORT, () => {
|
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) => {
|
.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}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue