Created
November 13, 2021 18:45
-
-
Save aleksejkozin/5acc75f4a7a1ddd3d236ba870e1b075e to your computer and use it in GitHub Desktop.
app.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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