balderdashy / balderdashy/sails
Standalone blueprint index route not working with prefix
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Sails version**: 1.0.2
**Node version**: 8.9.0
**NPM version**: 5.5.1
**DB adapter name**: N/A
**DB adapter version**: N/A
**Operating system**: Linux
I'm attempting to create blueprint routes. I have the following in config/blueprints.js:
```
actions: true,
prefix: '/api/v1',
```
Then I have the following at api/controllers/test/index.ts:
```
declare var sails: any;
export = {
friendlyName: 'Index',
description: 'Index test.',
inputs: {
},
exits: {
},
fn: async function (inputs, exits) {
return exits.success()
}
}
```
If I hit http://localhost:1337/test, I get an OK response. If I hit http://localhost:1337/api/v1/test I get a not found response. If I hit http://localhost:1337/api/v1/test/index, I again get OK. Not sure why test/index is even mounted at /test given I've specified a prefix, or why it's mounted incorrectly under the prefix.
I converted the TypeScript action to JS, same result. I also disabled my custom middlewares in case that was my issue, which it wasn't.
Thanks for any help.
Contributor guide
Research direction
Reproduce the routes using config/blueprints.js and the standalone action in api/controllers/test/index.ts. Start by tracing how the blueprint prefix is applied to standalone index actions, then verify the expected /api/v1/test and /api/v1/test/index behavior against the unprefixed route. Done means the prefixed index route works consistently and the unintended /test route no longer appears.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100