Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const nsq = require('nsq')
const crypto = require('crypto')
module.exports = async (req, res) => {
async validarAuth(req.header.authentication)
// Depois de validar iniciar a escuta em uma fila única para essa request
const replyQueue = crypto.randomBytes(30).toString('hex')
nsq.on(replyQueue, data => {
// Enviar para a queue do service
nsq.send('fazer_algo_no_db', {
user_id: req.user_id,
reply_to: replyQueue,
data: req.body
// timeout mal implementado :D
setTimeout(() => res.end(504), 2500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.