Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[idea] Support express.js path syntax #466

Open
OleksandrKucherenko opened this issue Feb 26, 2024 · 10 comments
Open

[idea] Support express.js path syntax #466

OleksandrKucherenko opened this issue Feb 26, 2024 · 10 comments

Comments

@OleksandrKucherenko
Copy link

Overview:

  • allow to copy/paster path/route definition from express without modifications

example: /users/:userId/books/:bookId

refs:

@Nandini1071
Copy link

Hi, is this issue still open?
If yes then what is the requirement, would like to contribute.

@OleksandrKucherenko
Copy link
Author

const client = forge({
  resources: {
    User: {
      all: { path: '/users' },

      // {id} is a dynamic segment and will be replaced by the parameter "id"
      // when called
      byId: { path: '/users/{id}' },

      // {group} is also a dynamic segment but it has default value "general"
      byGroup: { path: '/users/groups/{group}', params: { group: 'general' } },

      // {market?} is an optional dynamic segment. If called without a value
      // for the "market" parameter, {market?} will be removed from the path
      // including any prefixing "/".
      // This example: '/{market?}/users' => '/users'
      count: { path: '/{market?}/users' } }
    },
    Blog: {
      // The HTTP method can be configured through the `method` key, and a default
      // header "X-Special-Header" has been configured for this resource
      create: { method: 'post', path: '/blogs', headers: { 'X-Special-Header': 'value' } },

      // There are no restrictions for dynamic segments and HTTP methods
      addComment: { method: 'put', path: '/blogs/{id}/comment' },

      // `queryParamAlias` will map parameter names to their alias when
      // constructing the query string
      bySubject: { path: '/blogs', queryParamAlias: { subjectId: 'subject_id' } },

      // `path` is a function to map passed params to a custom path
      byDate: { path: ({date}) => `${date.getYear()}/${date.getMonth()}/${date.getDate()}` }
    }
  }
})

copy/paste from express routes definitions can simplify forge configuration greatly

@Nandini1071
Copy link

Hi, what is the requirement I mean is there any modification or feature addition in the above you mentioned?

@Nandini1071
Copy link

could you elaborate the requirement with proper file path.

@Nandini1071
Copy link

Please let me know the complete requirement on this, would like to contribute on that.

@Nandini1071
Copy link

Hi, could you provide requirement for this issue ?

@Nandini1071
Copy link

Hi @OleksandrKucherenko, could you explain the issue, what is required in detail.

@OleksandrKucherenko
Copy link
Author

Its not an issue, its the enhancment.

Most of the BE are done in expressjs, so when i need to create a client i should do a lot of copy/paste modifications.

Support of the expressjs route pathes by default will reduce the adoptation time.

@Nandini1071
Copy link

Nandini1071 commented Sep 2, 2024

so is there any thing on which I can contribute ?
@OleksandrKucherenko,

@klippx
Copy link
Collaborator

klippx commented Sep 2, 2024

Hmm., this must be an AI chatbot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants