improved api

This commit is contained in:
j-weissen 2022-12-05 19:30:27 +01:00
parent 3be0cc8380
commit f3f0945ccc
6 changed files with 174 additions and 7 deletions

View file

@ -10,14 +10,14 @@ const port = 3000
app.use(helmet())
// init database connection
const pgp = pgPromise({});
const db = pgp('postgres://postgres:postgres@localhost:5432/rr')
// configure & use logger
let morganFormatted = morgan('[:date[iso]] :method :url - :status')
app.use(morganFormatted);
// init database connection
const pgp = pgPromise({});
const db = pgp('postgres://postgres:postgres@localhost:5432/rr')
app.get('/highscore', async (req, res) => {
let data = await db.any(
@ -27,5 +27,5 @@ app.get('/highscore', async (req, res) => {
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
morganFormatted.log(`Server started at http://localhost:3000`);
})