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
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?)
This calls for https://youtu.be/nSKp2StlS6s
Dylan Beattie
YouTube
You Give REST a Bad Name
A parody of 'You Give Love a Bad Name' - about hypermedia APIs. No, really.
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 aproachyou 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)
mainly because I want to have two versions a productive and a development without having to run 2 bots
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
the bot integrates with game servers which have their api updated more often. but guess I could just have a second bot
why would you want your bot to have versioned routing though
is your bot's API going to be consumed by external people?
yes
I mean I'm hypocrite here because I do have versioning too
but I also have a public API
sooo
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
yeah I am going down that route
but I am not quite arsed yet
😄
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
rcon through a discord bot 😬
hope you encrypt those passwords!!
I don't even take passwords but yeah sadly those servers don#t support encrypted passwords using rcon
I meant storage wise
rcon as a protocol doesn't support encryption
if it wouldn't be for the community they wouldn't even be accessible from the outside other than rdp
but hey thanks for opening my eyes and thanks for creating sapphire, even though some parts of the documentation are missleading
oh I didn't create sapphire
if you have ideas or suggestions on certain parts of where we can improve docs, that'd be great
That credit goes to the blue people here
yeah I pr'd stuff but then I broke everything
don't thank me 😎
btw I previously used autocode, if you know that platform, but switched to selfhosting after they changed my 20€/m cost to 669€/m a week ago 😄
you're the second person to switch and end up here but I've never heard of the platform before
there might be more 😄 but most don't say that