Does plugin-api support parameters? If so, how can I get tem?

So basically I want to try and have some routes have optional url parameters, I know how this works with express as you can use and get them like this:
const router = express.Router();

router.get('/:id', (request: Request, response: Response) => {
response.status(200).json(request.params['id']);
})
const router = express.Router();

router.get('/:id', (request: Request, response: Response) => {
response.status(200).json(request.params['id']);
})
But I would like to do something like this with my sapphire plugin-api routes, are they like the same and how do I use these? Do sapphire's plugin-api package not support this or do they? Example below of what I intend to achieve:
import { methods, Route, type ApiRequest, type ApiResponse } from '@sapphire/plugin-api';

export class StatusRoute extends Route {
public constructor(context: Route.Context, options: Route.Options) {
super(context, {
...options,
route: 'user/:id',
});
}

public [methods.GET](request: ApiRequest, response: ApiResponse) {
return response.status(200).json(request.params['id']);
}
}
import { methods, Route, type ApiRequest, type ApiResponse } from '@sapphire/plugin-api';

export class StatusRoute extends Route {
public constructor(context: Route.Context, options: Route.Options) {
super(context, {
...options,
route: 'user/:id',
});
}

public [methods.GET](request: ApiRequest, response: ApiResponse) {
return response.status(200).json(request.params['id']);
}
}
Solution:
Nevermind, it was as exactly as I thought it might have been!
Jump to solution
4 Replies
Solution
edenn! \ (•◡•) /
Nevermind, it was as exactly as I thought it might have been!
Favna
Favna15mo ago
It’s nearly as if we implemented the REST spec kekGasm oh wait we did
Favna
Favna15mo ago
We at least try to prevent 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.
edenn! \ (•◡•) /
Sorry I've like only just discovered plugin-api T_T
Want results from more Discord servers?
Add your server