import express from 'express'; export default (connection) => { const app = new express(); app.disable('x-powered-by'); app.get( '/', async (req, res) => { res.send(); }, ) app.get( '/:id', async (req, res) => { console.log('called with', req.params.id) const [[ invite ]] = await connection.query(` SELECT token FROM invites WHERE id = '${req.params.id}' `) console.log(invite) if (invite) { console.log('sending') res.send(invite.token); } else { console.log(404) res.status(404).send(404); } }, ) app.use((err, req, res, next) => { res.status(500).send('There has been a serious infernal error :('); }) const port = process.env.PORT || 3002; app.listen(port, () => console.log('App listening on port ' + port)); }