API Routes Handling

I'm currently delving into routes and handling them but I have problems finding how to hand the process off to a middleware like express-routers. I want to essentially just forward every request to the express-router but I currently have 2 roadblocks: 1. the route parameter seems to not allow for wildcards 2. methods don't support handling all event types Maybe I just miss something obvious or what I want to do is impossible, feel free to correct me 😄
23 Replies
24
24•2y ago
what is your reasoning behind using express-router the point of api plugin is to avoid using express you either should use the API plugin, or write your own plugin using express. Don't mix the two. I'm curious to hear why you need wildcards and all event types (which I don't get?)
Favna
Favna•2y ago
Dylan Beattie
YouTube
You Give REST a Bad Name
A parody of 'You Give Love a Bad Name' - about hypermedia APIs. No, really.
Akanixon
Akanixon•2y ago
I love it 😄 mainly because I couldn't figure out how to have multiple levels to the path without having to create a new file for every possible route. like /v1/* which is handling some endpoints and then a new router for a larger subcategory /v1/utilities but I guess thats a bad aproach
24
24•2y ago
you can export multiple pieces from 1 file not necessarily a bad approach but I also have questions on why you'd want versioning on what would most likely be a private api (dashboard api)
Akanixon
Akanixon•2y ago
mainly because I want to have two versions a productive and a development without having to run 2 bots
24
24•2y ago
that's a really weird thing to do IMHO but not me, so don't care I would just make 2 methods in the file that have different routes but same logic
Akanixon
Akanixon•2y ago
the bot integrates with game servers which have their api updated more often. but guess I could just have a second bot
Favna
Favna•2y ago
why would you want your bot to have versioned routing though is your bot's API going to be consumed by external people?
Akanixon
Akanixon•2y ago
yes
24
24•2y ago
I mean I'm hypocrite here because I do have versioning too but I also have a public API sooo
Favna
Favna•2y ago
if your API is going to be consumed by external people you shouldn't integrate it into your bot IMHO if the only reason is Discord OAUTH2 then you should make tiny API on your bot using plugin-api that is called from your other external API that is build separately
24
24•2y ago
yeah I am going down that route but I am not quite arsed yet
Akanixon
Akanixon•2y ago
😄 yeah The api directly talks to some servers using rcon and some using telnet I guess I don't need that part inside the discord bot
24
24•2y ago
rcon through a discord bot 😬 hope you encrypt those passwords!!
Akanixon
Akanixon•2y ago
I don't even take passwords but yeah sadly those servers don#t support encrypted passwords using rcon
Want results from more Discord servers?
Add your server