diff --git a/examples/rest-api/index.ts b/examples/rest-api/index.ts index 6c83de2cd..e7720e303 100644 --- a/examples/rest-api/index.ts +++ b/examples/rest-api/index.ts @@ -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)