Per-folder Globals for Server Actions

Hi,

I’m requesting per-folder Globals. I want this feature:

For each Server Action folder.

The order of execution should be from outermost to innermost.

This would facilitate the development. For example:

POST /api/order/update?id=123

I could apply steps like Security Restrict and other more complex checks (i.e. is user allowed to access this order) directly to /api/order/, making it easier and less prone to missing security checks. In fact, this is the standard practice in modern MVC frameworks such as Laravel and AdonisJS.

Currently, I’m making a mess of Globals because I have this strategy for every resource, User, Order, etc., it’s a giant Globals - it would be best if it was scoped to each folder.

Bonus food for thought: Apply the same strategy to views (e.g. /order/update)

Wondering what would happen if you have a folder under API called order :thinking:

I didn't understand @franse

You have a folder called order under globals (this fr)

And you mention this path

I guess it's a SA under globals/order/update.json

But if you create a folder under api called order and a SA called update.json you'll have api/order/update which will be the exact same path as the one on global..

modules/global.json // (currently implemented)
api/order/update.json
api/order/_global.json

Something like that

Bump

I don't like using the globals since it makes it more difficult to see what an action does. I prefer to just use a library action which can be reused and include that at the top, then it is directly clear in the flow what exactly executes and it isn't much extra work.

When you have a _global.json in a folder, should it then execute after the globals and before the steps of the current action. What about nested folders, should they execute all the parent global files also or should it only apply to the current folder and not child folders?