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 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}`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue