Skip to content

Instantly share code, notes, and snippets.

@aleksejkozin
Created November 13, 2021 18:45
Show Gist options
  • Save aleksejkozin/5acc75f4a7a1ddd3d236ba870e1b075e to your computer and use it in GitHub Desktop.
Save aleksejkozin/5acc75f4a7a1ddd3d236ba870e1b075e to your computer and use it in GitHub Desktop.
app.js
const {Pool} = require('pg')
const express = require('express')
const {auth, requiresAuth} = require('express-openid-connect')
const app = express()
// Enable OIDC support
// To login into the app use cirnotoss@gmail.com/Lol2021
app.use(
auth({
issuerBaseURL: 'https://dev-2bsgb3hl.us.auth0.com',
baseURL: 'http://localhost:3000',
clientID: 'IkfMMemtSn9pukYyaZTXnwogRr9RSXFI',
// It is not safe to commit these secrets to GIT for a production app
secret: 'P6L2SYq7-KSrfit9gAtdeYAClC9EElvJ0bWSnjR2YXMVTmLNn-CgGRVzn-VaiglG',
}),
)
const pool = new Pool({
database: 'zyuiydzi',
host: 'chunee.db.elephantsql.com',
user: 'zyuiydzi',
port: 5432,
// It is not safe to commit these secrets to GIT for a production app
password: '9Up3OX_79y2A1RoIeYaxjf_xD02YpSKV',
})
app.get('/submissions', requiresAuth(), async (req, res) => {
const {rows} = await pool.query(
`
SELECT *
FROM submissions
WHERE created_by = $1
ORDER BY updated DESC
`,
[req?.oidc?.user?.email],
)
res.json(rows)
})
app.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment