const headerName = 'last-check';
document.body.addEventListener('htmx:configRequest', evt => {
const val = localStorage.getItem(keyName);
+ const secret = localStorage.getItem('secret');
event.detail.headers[headerName] = val;
+ event.detail.headers['x-secret'] = secret;
if(val) {
event.detail.headers['entry-count'] = document.querySelectorAll('.item').length;
}
});
app.post('/feed_entry/:feed_entry_id', async (req, res) => {
- const item: FeedWithEntrySchema[] = await db('feed_entry').update({
- is_read: true
- }).where({
- id: req.params.feed_entry_id
- }).returning('*');
+ const authSecret = req.header('x-secret');
- res.send(renderReaderAppFeedEntry(item.pop()));
+ if(authSecret === process.env.ADMIN_KEY) {
+ const item: FeedWithEntrySchema[] = await db('feed_entry').update({
+ is_read: true
+ }).where({
+ id: req.params.feed_entry_id
+ }).returning('*');
+
+ res.send(renderReaderAppFeedEntry(item.pop()));
+ }
+ else {
+ res.sendStatus(204).end();
+ }
});
app.delete('/feeds/:feed_id', async (req, res) => {