diff options
| -rw-r--r-- | bucky/app/federate.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bucky/app/federate.js b/bucky/app/federate.js index f4490c6..6741a21 100644 --- a/bucky/app/federate.js +++ b/bucky/app/federate.js @@ -4,16 +4,17 @@ var db = require('../db') module.exports = { route: (app) => { - app.put('/raw/import/thread/', importRaw(db.Thread), (req, res) => res.send({ status: 'ok' })) - app.put('/raw/import/keyword/', importRaw(db.Keyword), (req, res) => res.send({ status: 'ok' })) - app.put('/raw/import/file/', importRaw(db.File), (req, res) => res.send({ status: 'ok' })) - app.put('/raw/import/comment/', importRaw(db.Comment), (req, res) => res.send({ status: 'ok' })) + app.put('/raw/import/thread/', importRaw('thread', db.Thread), (req, res) => res.send({ status: 'ok' })) + app.put('/raw/import/keyword/', importRaw('keyword', db.Keyword), (req, res) => res.send({ status: 'ok' })) + app.put('/raw/import/file/', importRaw('file', db.File), (req, res) => res.send({ status: 'ok' })) + app.put('/raw/import/comment/', importRaw('comment', db.Comment), (req, res) => res.send({ status: 'ok' })) app.get('/raw/export/thread/:id', exportThread, (req, res) => res.send({ status: 'ok' })) app.get('/raw/export/keyword/:id', exportKeyword, (req, res) => res.send({ status: 'ok' })) - function importRaw (model) { + function importRaw (type, model) { return (req, res, next) => { + console.log('importing', type, req.body.id) new model(req.body).save().then((el) => { res.el = el; next() @@ -21,6 +22,7 @@ module.exports = { } } function exportKeyword (req, res, next) { + console.log('export keyword', req.params.keyword) db.getKeyword(req.params.keyword).then(keyword => { send("keyword", keyword) return db.getThreadsForKeyword(keyword) @@ -50,6 +52,7 @@ module.exports = { }) } function send(type, data){ + console.log('sending', type, data.get('id')) var json = data.toJSON() fetch("https://bucky.asdf.us/raw/import/" + type, { method: 'PUT', |
