balderdashy / balderdashy/sails

issue in custom response "notFound" and multiple hook

Open
#6,905 2 comments 0 reactions 0 assignees View on GitHub
helpful info or workaround
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Hi There,

version: v1.0

Looks like the sails have many issues or missing or not all information available in documentation. Today i started use sails and tried to modify "config" as given on sails documentation, below are the doubt and issue got.

i) as mentioned documentation, to customize the "notFound" response, have to create new "not found response" under "response" folder. but create new "notFound.js" how to tow diff output as per the request

- request having "json" output

output expected -> { message: 'page not found', status: 404 }

- request coming from direct "browser"

output expected -> display normal "404" page.

documentation URL:
https://sailsjs.com/documentation/reference/response-res/res-not-found

ii) as mentioned documentation, hooks are running before calling any controller or view, that's good but how to configuration to diff action check like below.

routes: {

before: {
'/api/*': { some action or validation code }, -- this only for api request, browser or ajax
'/*': { some action or validation code } -- this is for request coming direct browser, for page render
}
}

expected output:
when calling "api" reuqest other action should not get called. like only call action in '/api/*' not others.

Contributor guide

Open the contributing guide

Research direction

Start with the linked res-not-found documentation and the described response-folder and routes configuration. Reproduce the two notFound request cases and the overlapping hook patterns on Sails v1.0, then determine whether the documentation needs separate guidance for browser/API responses and route matching. Done means both questions have an agreed, documented configuration or a clearly identified framework limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.