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

Override the default request logic #13

Open
dalssoft opened this issue May 22, 2021 · 2 comments
Open

Override the default request logic #13

dalssoft opened this issue May 22, 2021 · 2 comments
Labels

Comments

@dalssoft
Copy link
Member

Having a default request logic (how the req info is dealt for each type of route) is useful but forcing it is bad. There should be a way to override it for certain use cases.

Suggested UX:

const myRequest = (req) => { return Object.assign({}, req.query, req.params) }

const controllerList = [
  {
    name: 'lists',
    idParameter: 'listId',
    getAll: require('../usecases/getLists'),
    getById: { usecase: require('../usecases/getLists'), request: myRequest }, // my request
    ...
  }
]
@dalssoft dalssoft added the enhancement New feature or request label May 22, 2021
@italojs
Copy link
Member

italojs commented Sep 21, 2021

I think we need only specify the request, because in my request I will build my own logic to call my usecase:

const controllerList = [
  {
    name: 'lists',
    idParameter: 'listId',
    getAll: require('../usecases/getLists'),
    getById:  (req, res, next) => { 
        // [...] controller logic
        const result = usecase.run()
        res.json(result)
       }
    ...
  }
]

@dalssoft
Copy link
Member Author

the issue is specific on how to deal with variable coming from query string, body and params.

that is the current implementation:

const reqFields = { ...req.body, ...req.query }

but overriding it should be possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Ready to code
Development

No branches or pull requests

3 participants