Skip to content
Snippets Groups Projects
Commit f4468a21 authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

saved author in db

parent 78d5f16e
No related branches found
No related tags found
No related merge requests found
Showing
with 38 additions and 32 deletions
_build/
api/
logs/
node_modules/
uploads/
.env.*
.env
config/local*.*
\ No newline at end of file
module.exports = {
backend: () => app => require('./src/AuthorBackend')(app),
}
const bodyParser = require('body-parser')
const AuthorBackend = app => {
app.get('/api/author', (req, res, next) => {
console.log(app)
res.status(400).json({ error: 'Username must be specified' })
})
app.post(
'/api/:fragmentId/author',
bodyParser.json(),
async (req, res, next) => {
try {
let fragment = await app.locals.models.Fragment.find(
req.params.fragmentId,
)
fragment.authors = fragment.authors ? fragment.authors : []
fragment.authors.push(req.body)
fragment = await fragment.save()
res.status(200).json(fragment)
} catch (e) {
res.status(400).json({ error: e })
}
},
)
}
module.exports = AuthorBackend
module.exports = {
server: () => app => require('./AuthorBacked')(app),
}
_build/
api/
logs/
node_modules/
uploads/
.env.*
.env
config/local*.*
\ No newline at end of file
{
"pubsweet-client": {
"API_ENDPOINT": "/api",
"login-redirect": "/",
"redux-log": false
},
"authsome": {
"mode": "/Users/sebi/Work/xpub/packages/xpub-faraday/config/authsome.js",
"teams": {}
},
"validations": "/Users/sebi/Work/xpub/packages/xpub-faraday/config/validations.js"
}
MANIFEST-000002
2018/01/10-12:49:58.611387 70000e61a000 Delete type=3 #1
MANIFEST-000007
2018/01/10-14:08:52.018050 700008326000 Recovering log #6
2018/01/10-14:08:52.018366 700008326000 Level-0 table #8: started
2018/01/10-14:08:52.018731 700008326000 Level-0 table #8: 691 bytes OK
2018/01/10-14:08:52.019493 700008326000 Delete type=0 #6
2018/01/10-14:08:52.019619 700008326000 Delete type=3 #4
2018/01/10-13:57:40.119745 7000120ea000 Recovering log #3
2018/01/10-13:57:40.120013 7000120ea000 Level-0 table #5: started
2018/01/10-13:57:40.120334 7000120ea000 Level-0 table #5: 339 bytes OK
2018/01/10-13:57:40.121089 7000120ea000 Delete type=0 #3
2018/01/10-13:57:40.121247 7000120ea000 Delete type=3 #2
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment