improved api
This commit is contained in:
parent
3be0cc8380
commit
f3f0945ccc
6 changed files with 174 additions and 7 deletions
|
|
@ -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`);
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue