Sapphire - Imagine a framework
Sapphire - Imagine a framework

sapphire-support

Root Question Message

Akanixon
Akanixon1/15/2023
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 😄
24
241/15/2023
what is your reasoning behind using express-router
24
241/15/2023
the point of api plugin is to avoid using express
24
241/15/2023
you either should use the API plugin, or write your own plugin using express. Don't mix the two.
24
241/15/2023
I'm curious to hear why you need wildcards and all event types (which I don't get?)
Favna
Favna1/15/2023
Akanixon
Akanixon1/15/2023
I love it 😄
Akanixon
Akanixon1/15/2023
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
Akanixon
Akanixon1/15/2023
but I guess thats a bad aproach
24
241/15/2023
you can export multiple pieces from 1 file
24
241/15/2023
not necessarily a bad approach
24
241/15/2023
but I also have questions on why you'd want versioning on what would most likely be a private api (dashboard api)
Akanixon
Akanixon1/15/2023
mainly because I want to have two versions a productive and a development without having to run 2 bots
24
241/15/2023
that's a really weird thing to do IMHO
24
241/15/2023
but not me, so don't care
24
241/15/2023
I would just make 2 methods in the file that have different routes but same logic
Akanixon
Akanixon1/15/2023
the bot integrates with game servers which have their api updated more often. but guess I could just have a second bot
Favna
Favna1/15/2023
why would you want your bot to have versioned routing though
Favna
Favna1/15/2023
is your bot's API going to be consumed by external people?
Akanixon
Akanixon1/15/2023
yes
24
241/15/2023
I mean I'm hypocrite here because I do have versioning too
24
241/15/2023
but I also have a public API
24
241/15/2023
sooo
Favna
Favna1/15/2023
if your API is going to be consumed by external people you shouldn't integrate it into your bot IMHO
Favna
Favna1/15/2023
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
241/15/2023
yeah I am going down that route
24
241/15/2023
but I am not quite arsed yet
Akanixon
Akanixon1/15/2023
😄
Akanixon
Akanixon1/15/2023
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
241/15/2023
rcon through a discord bot 😬
24
241/15/2023
hope you encrypt those passwords!!
Akanixon
Akanixon1/15/2023
I don't even take passwords but yeah sadly those servers don#t support encrypted passwords using rcon
24
241/15/2023
I meant storage wise
24
241/15/2023
rcon as a protocol doesn't support encryption
Akanixon
Akanixon1/15/2023
if it wouldn't be for the community they wouldn't even be accessible from the outside other than rdp
Akanixon
Akanixon1/15/2023
but hey thanks for opening my eyes and thanks for creating sapphire, even though some parts of the documentation are missleading
24
241/15/2023
oh I didn't create sapphire
24
241/15/2023
if you have ideas or suggestions on certain parts of where we can improve docs, that'd be great
Favna
Favna1/15/2023
That credit goes to the blue people here :coolkirb:
24
241/15/2023
yeah I pr'd stuff but then I broke everything
24
241/15/2023
don't thank me 😎
Akanixon
Akanixon1/15/2023
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 😄
Favna
Favna1/15/2023
you're the second person to switch and end up here but I've never heard of the platform before
Akanixon
Akanixon1/15/2023
there might be more 😄 but most don't say that
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy