A RegexP, string-representation of the Route Path.
global use: (Auth|Data).Routemethod use: (Auth|Data).MethodA flag the specifies whether or not, and if so, how to prepend the path-parameters of the last parent-Endpoint
referenced in Sub (along with the merge of its own parent; if applicable) to the path-name/parameters
of this Endpoint:
true, the Scheme from the parent-Endpoint will be prepended to this Scheme of this Endpoint.parent-Endpoint's
CBRouteAU/CBRouteDB definition of the same HMETHOD. Otherwise, it choose the first
Scheme found within each parent.method (see: Uses below), and set to true, then the system will look for that method
deinition within the parent and choose that Scheme. Otherwise, the first Scheme found
is chosen.({
User: {
Actions: {
Password: new RouteDB({
Merge: true,
Subs: ['settings','privacy'], // Child of "Settings"
GET: () => ({ ... }), // Merge to "Privacy.GET"
// ^ Resolves to "/user/:uid/settings/privacy/:prv_id/password"
}),
Email: new RouteDB({
Merge: 'POST', // Merge to "Privacy.POST"
Subs: ['settings','privacy'], // Child of "Settings"
GET: () => ({ ... }),
// ^ Resolves to "/user/:uid/settings/privacy/email"
}),
Privacy: new RouteDB({
Scheme: '/:prv_id/', // Defult for any Method defined within
Subs: ['settings'], // Child of "Settings".
Merge: true,
GET: () => ({ ... }),
// ^ Merge to "Settings.GET",
// ^ Resolves to "/user/:uid/settings/privacy/:prv_id"
POST: () => ({ Scheme: '/' })
// ^ Merge to "Settings.GET", Scheme redefined to "/"
// ^ Resolves to "/user/:uid/settings/privacy"
}),
Settings: new RouteDB({
Merge: true,
GET: () => ({ ... }),
// ^ Sub not defined, is child of "/"
// ^ Resolves to "/user/:uid/settings"
}),
"/": new RouteDB({
Scheme: '/:uid/',
GET: () => ({ ... }),
// ^ Resolves to "/user/:uid"
}),
}
}
});
global: (Auth|Data).Routemethod: (Auth|Data).MethodA list of Limits to subscribe to.
global use: (Auth|Data).Routemethod use: (Auth|Data).MethodThe documentation for Methods in this Route.
global use: (Auth|Data).Routemethod use: (Auth|Data).MethodA collection of GNParams, which represent the global or method-specific path/query/body parameters of an Endpoint:
global use: (Auth|Data).Routemethod use: (Auth|Data).MethodThese can be defined inline:
{
async Query() { ... },
Params: {
UserID: new GNParam({
Name: 'User ID',
Default: null,
Format (cls) { return cls.user_id; },
// ...
}),
},
Parse(res) { ... },
}
Or defined in a CFG.PNTS.Defaults object within config/authpoints.cfg.js or config/endpoints.cfg.js:
{
__DEFAULTS: {
Header: { ... },
Params: {
// Define as a Default...
UserID: new GNParam({ ... }),
}
},
User: {
Actions: {
Settings: new RouteDB({
Params: {
// ... Reference the default.
UserID: true,
}
}),
},
},
}
When defined using the latter technique, references to those predefined GNParams are made in the following ways:
| Reference | Example | Description |
|---|---|---|
Direct |
{ Email: true } |
References the param defined in __DEFAULTS. |
Version |
{ Email: ['REQUIRED'] } |
References a required version of the Email Param. |
The collection of handlers for an Auth.Method.
Either an Array of Strings that form a SQL query, or A callback that retrieves/updates
backned data for an Data.Method.
A string that refers to a property-key of an Object-interface property within any Data.Method result
returned as an Array<{ key: value, ...rest }>. When this is set, the internal-parser will transform the Array<{ key: value, ...rest }> into
Object<key,{ key: value, ...rest }>, removing the property from each item in the Object that now serves as the key of each item-value.
({
Query: (cls) => ([
{ user_id: 1, name: 'Hello', age: 102 },
{ user_id: 2, name: 'World', age: 20 },
{ user_id: 3, name: 'Foo', age: 31 },
{ user_id: 4, name: 'Bar', age: 46 },
]),
Key: 'user_id',
});
// payload.result = {
// 1: { name: 'Hello', age: 102 },
// 2: { name: 'World', age: 20 },
// 3: { name: 'Foo', age: 31 },
// 4: { name: 'Bar', age: 46 },
// }
global use: Data.Routemethod use: Data.Methodtrue, if this Endpoint is restricted to Admins.
global use: (Auth|Data).Routemethod use: (Auth|Data).MethodAn optional callback that handles any post-formatting needed before the result of a method is attached to the payload for consumption.
This may seem redundant when using Data.Method.Query (as a CBQYHandle, not a SQL string[]), but
when a particular Enpdpoint responds to multiple HMETHODs, the result-structure is usually the same. This property can be exploited by defining it
globally inside of the Data.Method config. For every CBRouteDB contained within the CFGRouteQry*, this callback will
be applied. That way, you need only define it once.
Of course, if a certain format is required across multiple Endpoints, one can always define the callback outside of the {@link CFGAuthPointsDB} config
and assign it to Parse.
If this is not defined, the internal-parser will do what it does. This is generally just dumping whatever was returned; unless the result returned is
of Array<Object<key,value>>, and Key maps to one of the item's keys.
global use: Data.Routemethod use: Data.Method
Config properties for the QueryGN object.