Skip to content

Instantly share code, notes, and snippets.

@dbarkol
Created June 30, 2020 06:02
Show Gist options
  • Save dbarkol/4a629bb409cebfefcdeab6543c8bcfc8 to your computer and use it in GitHub Desktop.
Save dbarkol/4a629bb409cebfefcdeab6543c8bcfc8 to your computer and use it in GitHub Desktop.
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
app.use(bodyParser.json({ type: 'application/*+json' }));
const port = 3000
app.get('/dapr/subscribe', (req, res) => {
res.json([
{
topic: "songs",
route: "playlist"
}
]);
})
app.post('/playlist', (req, res) => {
let song = req.body.data;
console.log("New song request: " + song.artist + " - " + song.name);
res.sendStatus(200);
});
app.listen(port, () => console.log(`consumer app listening on port ${port}!`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment