Browse Source

AND also in createRouter

master
Rich Brown 1 year ago
parent
commit
daccee9d7e
1 changed files with 12 additions and 10 deletions
  1. +12
    -10
      routes/createRouter.js

+ 12
- 10
routes/createRouter.js View File

@@ -4,7 +4,7 @@ import express from 'express';
const createRouter = express.Router();

createRouter.post('/', (req, res) => {
const { text, me } = req.body;
const { text } = req.body;
let { tags, title } = req.body;
if (!text || text === '' || typeof text !== 'string') {
return res.status(400).json({ error: 'Invalid or missing text.', url: null });
@@ -15,19 +15,21 @@ createRouter.post('/', (req, res) => {
}

if (title === '') {
return req.app.locals[me]
return req.app.locals.mp
.create({ h: 'entry', content: text, category: tags }, 'form') // TODO: test categories/tags
.then(url => res.json({ error: null, url }))
.catch(() => res.status(400).json({ error: 'micropub-helper failed; form', url: null }));
}
return req.app.locals[me]
.create({
h: 'entry',
name: title, // i thought MF syntax was 'p-name' but voxpelli's formatter turns NAME to TITLE
content: text,
category: tags,
},
'multipart')
return req.app.locals.mp
.create(
{
h: 'entry',
name: title, // i thought MF syntax was 'p-name' but voxpelli's formattr turns NAME to TITLE
content: text,
category: tags,
},
'multipart',
)
.then(url => res.json({ error: null, url }))
.catch(() => res.status(400).json({ error: 'micropub-helper failed; multipart', url: null }));
});


Loading…
Cancel
Save