Skip to content

autoPrefix overwrites directory path set by dirNameRoutePrefix #205

Open
@mariusa

Description

@mariusa

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Hi,

Using the example from README

plugins
│   ├── hooked-plugin
│   │   ├── autohooks.js // req.hookOne = 'yes' # CJS syntax
│   │   ├── routes.js
│   │   └── children
│   │       ├── old-routes.js
│   │       ├── new-routes.js
│   │       └── grandchildren
│   │           ├── autohooks.mjs // req.hookTwo = 'yes' # ESM syntax
│   │           └── routes.mjs
│   └── standard-plugin
│       └── routes.js

Say new-routes.js has a route with fastify.patch('/entity', ...

That is available at http://.../hooked-plugin/children/entity , as by default dirNameRoutePrefix is set. So far so good.

In new-routes.js, I've set

export const autoPrefix = '/batch'

I would have expected the route to be now at http://.../hooked-plugin/children/batch/entity but instead is at
http://.../hooked-plugin/batch/entity
If this is intended behavior, would you please mention in README for autoPrefix that it overwrites, not appends, to folder structure path?
This isn't consistent with When setting both options.prefix and plugin.autoPrefix they will be concatenated., but at least it's documented.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions