summaryrefslogtreecommitdiff
path: root/bucky
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-15 07:36:55 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-15 07:36:55 +0100
commit5b07e44b5707341e168c8aaed9923cb433ffca82 (patch)
tree9d7f212efa81827afbaecde448c39cfb9609c12c /bucky
parentb2fc10f4d7bba8489a6c98a206d4a51874c19234 (diff)
log
Diffstat (limited to 'bucky')
-rw-r--r--bucky/app/federate.js13
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',