Skip to content

Commit

Permalink
docs: Added some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Feb 12, 2020
1 parent 372cd25 commit 17fe219
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion examples/rest-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ app.post('/handle-action', express.json(), async (req, res) => {
res.json({ result })
})

// This endpoint would be published in did doc as a serviceEndpoint
app.post('/handle-message', express.text({ type: '*/*' }), async (req, res) => {
try {
const result = await core.validateMessage(
new Message({ raw: req.body, meta: { type: 'serviceEndpoint', id: '/handle-message' } }),
new Message({ raw: req.body, meta: { type: 'serviceEndpoint', id: 'handle-message' } }),
)

// now you can store this message or pass through to some webhook

res.json({ id: result.id })
} catch (e) {
res.send(e.message)
Expand Down

0 comments on commit 17fe219

Please sign in to comment.