app.get('/success', (request, reply) => { const schnackDomain = getSchnackDomain(); reply.send(`<script> document.domain = '${schnackDomain}'; window.opener.__schnack_wait_for_oauth(); </script>`); });
router.use('/users', (req, res, next) => { if (req.user && req.user.isAdmin) { next(); return; } res.status(401).send('Not authorized'); });
// settings app.post('/setting/:property/:value', (request, reply) => { const { property, value } = request.params; const user = getUser(request); if (!isAdmin(user)) return reply.status(403).send(request.params); const setting = value ? 1 : 0; db.run(queries.set_settings, [property, setting], err => { if (error(err, request, reply)) return; reply.send({ status: 'ok' }); }); });
api.post('/hook', function (req, res) { var signature = req.get('X-PDF-Signature', 'sha1=') var bodyCrypted = require('crypto') .createHmac('sha1', '12345') .update(JSON.stringify(req.body)) .digest('hex') if (bodyCrypted !== signature) { res.status(401).send() return } console.log('PDF webhook received', JSON.stringify(req.body)) res.status(204).send() })
app.get('/signout', (request, reply) => { delete request.session.passport; reply.send({ status: 'ok' }); });
// for markdown preview app.post('/markdown', (request, reply) => { const { comment } = request.body; reply.send({ html: marked(comment.trim()) }); });
// trust/block users or approve/reject comments app.post( /\/(?:comment\/(\d+)\/(approve|reject))|(?:user\/(\d+)\/(trust|block))/, (request, reply) => { const user = getUser(request); if (!isAdmin(user)) return reply.status(403).send(request.params); const action = request.params[1] || request.params[3]; const target_id = +(request.params[0] || request.params[2]); db.run(queries[action], target_id, err => { if (error(err, request, reply)) return; reply.send({ status: 'ok' }); }); } );
router.get('/logout', (req, res) => { res.clearCookie('jwt').send(); });
app.express.get('/_ah/health', (req, res) => { res.status(200).send('OK '+Date.now()); });
app.get('/healthz', function (req, res) { // do app logic here to determine if app is truly healthy // you should return 200 if healthy, and anything else will fail // if you want, you should be able to restrict this to localhost (include ipv4 and ipv6) res.send('I am happy and healthy\n'); });
app.express.get('/', (req, res) => { res.status(200).send('home'); });
app.get('/', function (req, res) { res.send('Hello Docker World\n'); });
app.get('/', (request, reply) => { reply.send({ test: 'ok' }); });
app.get('/', (req, res) => { res.send('Hello World!') })