Consider a lightweight option for path-only functionality #54
mattwigham
started this conversation in
Ideas
Replies: 1 comment
-
Hi Matt! This usage seems like something that would be nice to cover in the docs, and maybe have an example repo. I always recommend using custom code, as that makes it easier to build upon the provided client libraries. config.client_library = '~/services/api' so your solution is what I would typically use if I wanted that behavior. When using TypeScript, you can leverage // app/frontend/services/api.ts
import { formatUrl, type UrlOptions } from '@js-from-routes/core'
export function definePathHelper (_method: string, pathTemplate: string) {
return (options?: UrlOptions) => formatUrl(pathTemplate, options)
} That will provide better type-checking, or autocompletion if mostly using JS. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thanks @ElMassimo for such a great lib.
For my project, I needed a way to generate paths in JS, but I didn't need the client features since I already had those elsewhere.
I was able to create a more lightweight version for path-only functionality using the custom client library below, but I thought you might consider adding something like this as an option, or even the default, and let people opt-in to the additional client features if they need them.
which simplifies usage to...
Beta Was this translation helpful? Give feedback.
All reactions