#What's the best package for service-to-service calls..
27 messages · Page 1 of 1 (latest)
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
✅Marked as resolved by OP
I‘m just as confused by your question. You don’t use express along with express? What kind of request do you want to do to discord.js (assuming you just mean a REST request to discord API you should use @discordjs/rest or /core instead of full discord.js)
Can you rephrase your question. Currently, it's very confusing
router.post('/events', async (req, res, next) => {
res.setHeader('Content-Type', "text/event-stream");
res.setHeader('Cache-Control', 'no-cache');
res.setHeader('Connection', 'keep-alive');
res.write(`data: ${JSON.stringify({ message: "Saving Data", progress: 25 })}`);
setTimeout(() => {
res.write(`\ndata: ${JSON.stringify({ message: "Creating Role", progress: 50 })}`);
}, 3000);
setTimeout(() => {
res.write(`\ndata: ${JSON.stringify({ message: "Assigning Role", progress: 75 })}`);
}, 6000);
setTimeout(() => {
res.write(`\ndata: ${JSON.stringify({ message: "Completed..", progress: 100 })}`);
}, 9000);
setTimeout(() => {
res.end();
}, 12000);
res.on('close', () => {
res.end();
})
})
This is a sample code which returns some stream data using express.. On each, I need to make a request to bot side and i should get a response also... I implemented it using socket io but IT'S A LOT OF EVENTS
what kind of request and what is "bot side" here? another node process running your bot with djs? djs running in the same process? or direct requests to discord without having a logged in djs bot with gateway connection?
another node process with discord.js
with api?
what kind of request?
and what do you mean by "with api"?
but you know, dealing discord api with discord.js is kinda ezzz
request = request to start a process like creating a role with the name passed from the above code, assign the created role to a member
with api = by using discord api mannually in the express node process
then use either @discordjs/rest to send the raw requests or @discordjs/core to have typed functions for the request routes
GuildsAPI#addRoleToMember() @1.2.0
Adds a role to a guild member
oke... thank you for the response. Let me see if I've any other doubts.. really thanks
oke, this package helps me a lot.. but i think i should connect with discord.js application to handle them properly.. so is there any packages which i can use for service-to-service calls? like I need to request (a process to create) and i should get a responce from the djs node process
make an API server with express
yeah. I created it.. But i don't like using express along with djs
So you want to do it. While not doing it… what exactly is it you want?
I just need to request a process from the express application to djs node process (both are different applications)..
so for that, what's the best package for service-to-service calls ( i should get a responce too)
„Request a process“? Wdym by that?
to create a role or something related to djs
And why are you
- not doing the API request to discord that does that from the express app or
- run the express endpoint from the djs app?
Because what you call service-to-service calls is nothing else but an API
something like realtime thing?
kinda confused myself.. lemme research something
I‘m sorry but it‘s hard to follow what you mean… yeah