mirror of
https://github.com/dariusk/express-activitypub.git
synced 2024-11-21 23:01:01 +00:00
62f0fa88dd
Addresses #1.
23 lines
582 B
JavaScript
23 lines
582 B
JavaScript
'use strict';
|
|
const express = require('express'),
|
|
router = express.Router();
|
|
|
|
router.get('/:guid', function (req, res) {
|
|
let guid = req.params.guid;
|
|
if (!guid) {
|
|
return res.status(400).send('Bad request.');
|
|
}
|
|
else {
|
|
let db = req.app.get('db');
|
|
db.get('select message from messages where guid = $guid', {$guid: guid}, (err, result) => {
|
|
if (result === undefined) {
|
|
return res.status(404).send(`No record found for ${guid}.`);
|
|
}
|
|
else {
|
|
res.json(JSON.parse(result.message));
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|