Skip to content

Commit

Permalink
Add web publish endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeBild committed Dec 10, 2017
1 parent 5a6b4b5 commit ad6cac7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "subscriptions-transport-sse",
"version": "0.7.7",
"version": "0.7.8",
"author": "Mike Bild <mike.bild@googlemail.com>",
"license": "MIT",
"homepage": "https://github.com/mikebild/subscriptions-transport-sse#readme",
Expand Down
6 changes: 3 additions & 3 deletions src/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export function SubscriptionServer(subscriptionOptions, connectionOptions) {
});

connectionOptions.express.post(
`${connectionOptions.path}/publish/:id`,
`${connectionOptions.path}/publish/:topic?`,
(req, res) => {
const connectionSubscriptionId = req.params.id;
const topic = req.params.topic || 'event-web-publish';
const data = req.body || {};
res.setHeader('Content-Type', 'application/json');
emitter.emit(`event-${connectionSubscriptionId}`, null, {data});
subscriptionOptions.subscriptionManager.pubsub.publish(topic, data);
res.sendStatus(202);
}
);
Expand Down

0 comments on commit ad6cac7

Please sign in to comment.