The HTTP-Methods that this Endpoint can be called with. This can be exploited to allow a single-hanlder
(GET, for example) repsond to other HMETHODs (such as, POST).
A list of the heirarchy Endpoints contained within it's Base that it belongs under.
By default, any Endpoint defined within a BasePoint -- except, of course, for "/" --
is a direct descendant of "/", as "/" is just the definition of the BasePoint without
any other paths following it. But obviously there are needs to push the heirarchy further.
Instead of forcing developers to use a Parant > Child structure that would get very annoying, very
fast, heirarchies are defined using this property. As was said earlier, "/", is inherited by all
other Endpoints contained with a BaseEndpoint, so it doesn't need to be add here. If the
Endpoint in question is to remain a direct descendant of "/", then this need not be defined.
Depending on whether or not Merge is configured, the path will be resolved differently.
({
User: {
Actions: {
Email: new RouteDB({
Scheme: '/',
Merge: true,
Subs: ['settings'], // defined, child of "Settings", Merge
// Resolves to "/user/settings/:sttg_id/email"
}),
Privacy: new RouteDB({
Scheme: '/:uid/',
Subs: ['settings'], // defined, child of "Settings", no Merge
// Resolves to "/user/settings/privacy/:uid"
}),
Settings: new RouteDB({
Scheme: '/:sttg_id/', ...
// Sub not defined, is child of "/", no Merge
}),
"/": new RouteDB({
Scheme: '/:uid/', ...
// Resolves to "/user/:uid"
}),
}
}
});
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 callback that returns configs for a GET method within a Route.
A callback that returns configs for a POST method within a Route.
A callback that returns configs for a PUT method within a Route.
A callback that returns configs for a DELETE method within a Route.
A callback that returns configs for a MID method within a RouteAU request.
A 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. |
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.MethodA list of Request Paths used for linking RouteDB requests.
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
GNRequestobject.