vovk 3.0.0-draft.444 → 3.0.0-draft.445
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/client/createRPC.js
CHANGED
|
@@ -24,10 +24,16 @@ const createRPC = (givenSchema, segmentName, rpcModuleName, givenFetcher, option
|
|
|
24
24
|
const segmentSchema = schema.segments[segmentName];
|
|
25
25
|
if (!segmentSchema)
|
|
26
26
|
throw new Error(`Unable to create RPC module. Segment schema is missing for segment "${segmentName}".`);
|
|
27
|
-
|
|
27
|
+
let controllerSchema = schema.segments[segmentName]?.controllers[rpcModuleName];
|
|
28
28
|
const client = {};
|
|
29
29
|
if (!controllerSchema) {
|
|
30
|
-
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.warn(`Unable to create RPC module. Controller schema is missing for module "${rpcModuleName}" from segment "${segmentName}". Assuming that schema is not ready yet.`);
|
|
32
|
+
controllerSchema = {
|
|
33
|
+
rpcModuleName,
|
|
34
|
+
prefix: '',
|
|
35
|
+
handlers: {},
|
|
36
|
+
};
|
|
31
37
|
}
|
|
32
38
|
const controllerPrefix = trimPath(controllerSchema.prefix ?? '');
|
|
33
39
|
const forceApiRoot = controllerSchema.forceApiRoot ?? segmentSchema.forceApiRoot;
|
package/cjs/utils/multitenant.js
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Function "multitenant" accepts an object with "requestUrl", "requestHost", "targetHost" and "overrides" properties.
|
|
4
|
-
The requestHost parameter comes from request headers and should be used instead of the hostname in the requestUrl.
|
|
5
|
-
The keys in overrides are subdomains relative to the "targetHost". They can include a dot to indicate lower-level
|
|
6
|
-
subdomains, and can use square brackets to indicate wildcard values. The values are arrays of objects with "from"
|
|
7
|
-
and "to" properties, which are strings indicating the override paths for Next.js.
|
|
8
|
-
|
|
9
|
-
If a path matches a specific subdomain name (e.g., "/admin" matches the "admin" subdomain),
|
|
10
|
-
the request will be redirected to that specific subdomain instead of being processed on the current subdomain.
|
|
11
|
-
|
|
12
|
-
If a path ends with "_schema_", it will not be processed by any overrides and will be passed through as-is.
|
|
13
|
-
|
|
14
|
-
Example:
|
|
15
|
-
|
|
16
|
-
const { action, destination, message, subdomains } = multitenant({
|
|
17
|
-
requestUrl: request.url,
|
|
18
|
-
requestHost: request.headers.get('host'),
|
|
19
|
-
targetHost: "localhost:3000",
|
|
20
|
-
overrides: {
|
|
21
|
-
"[customer_name].customer": [
|
|
22
|
-
{ from: "api", to: "api/customer" }, // API
|
|
23
|
-
{ from: "", to: "[customer_name]" } // UI
|
|
24
|
-
],
|
|
25
|
-
"pro.[customer_name].customer": [
|
|
26
|
-
{ from: "api", to: "api/customer/pro" }, // API
|
|
27
|
-
{ from: "", to: "pro/[customer_name]" } // UI
|
|
28
|
-
],
|
|
29
|
-
"admin": [
|
|
30
|
-
{ from: "api", to: "api/admin" }, // API
|
|
31
|
-
{ from: "", to: "admin" } // UI
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
subdomains is a Record<string, string> | null where keys are subdomain names and values are their corresponding values. If non-wildcard subdomains are used, should be equal to null.
|
|
37
|
-
action is one of "rewrite", "redirect", "notfound", or null.
|
|
38
|
-
message is a string describing the action taken
|
|
39
|
-
destination is a string URL to redirect or rewrite to, or null if no action is taken or "notfound"
|
|
40
|
-
*/
|
|
41
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
3
|
exports.multitenant = multitenant;
|
|
43
4
|
// Get the reserved paths from the overrides configuration
|
package/mjs/client/createRPC.js
CHANGED
|
@@ -24,10 +24,16 @@ const createRPC = (givenSchema, segmentName, rpcModuleName, givenFetcher, option
|
|
|
24
24
|
const segmentSchema = schema.segments[segmentName];
|
|
25
25
|
if (!segmentSchema)
|
|
26
26
|
throw new Error(`Unable to create RPC module. Segment schema is missing for segment "${segmentName}".`);
|
|
27
|
-
|
|
27
|
+
let controllerSchema = schema.segments[segmentName]?.controllers[rpcModuleName];
|
|
28
28
|
const client = {};
|
|
29
29
|
if (!controllerSchema) {
|
|
30
|
-
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.warn(`Unable to create RPC module. Controller schema is missing for module "${rpcModuleName}" from segment "${segmentName}". Assuming that schema is not ready yet.`);
|
|
32
|
+
controllerSchema = {
|
|
33
|
+
rpcModuleName,
|
|
34
|
+
prefix: '',
|
|
35
|
+
handlers: {},
|
|
36
|
+
};
|
|
31
37
|
}
|
|
32
38
|
const controllerPrefix = trimPath(controllerSchema.prefix ?? '');
|
|
33
39
|
const forceApiRoot = controllerSchema.forceApiRoot ?? segmentSchema.forceApiRoot;
|
package/mjs/utils/multitenant.js
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Function "multitenant" accepts an object with "requestUrl", "requestHost", "targetHost" and "overrides" properties.
|
|
4
|
-
The requestHost parameter comes from request headers and should be used instead of the hostname in the requestUrl.
|
|
5
|
-
The keys in overrides are subdomains relative to the "targetHost". They can include a dot to indicate lower-level
|
|
6
|
-
subdomains, and can use square brackets to indicate wildcard values. The values are arrays of objects with "from"
|
|
7
|
-
and "to" properties, which are strings indicating the override paths for Next.js.
|
|
8
|
-
|
|
9
|
-
If a path matches a specific subdomain name (e.g., "/admin" matches the "admin" subdomain),
|
|
10
|
-
the request will be redirected to that specific subdomain instead of being processed on the current subdomain.
|
|
11
|
-
|
|
12
|
-
If a path ends with "_schema_", it will not be processed by any overrides and will be passed through as-is.
|
|
13
|
-
|
|
14
|
-
Example:
|
|
15
|
-
|
|
16
|
-
const { action, destination, message, subdomains } = multitenant({
|
|
17
|
-
requestUrl: request.url,
|
|
18
|
-
requestHost: request.headers.get('host'),
|
|
19
|
-
targetHost: "localhost:3000",
|
|
20
|
-
overrides: {
|
|
21
|
-
"[customer_name].customer": [
|
|
22
|
-
{ from: "api", to: "api/customer" }, // API
|
|
23
|
-
{ from: "", to: "[customer_name]" } // UI
|
|
24
|
-
],
|
|
25
|
-
"pro.[customer_name].customer": [
|
|
26
|
-
{ from: "api", to: "api/customer/pro" }, // API
|
|
27
|
-
{ from: "", to: "pro/[customer_name]" } // UI
|
|
28
|
-
],
|
|
29
|
-
"admin": [
|
|
30
|
-
{ from: "api", to: "api/admin" }, // API
|
|
31
|
-
{ from: "", to: "admin" } // UI
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
subdomains is a Record<string, string> | null where keys are subdomain names and values are their corresponding values. If non-wildcard subdomains are used, should be equal to null.
|
|
37
|
-
action is one of "rewrite", "redirect", "notfound", or null.
|
|
38
|
-
message is a string describing the action taken
|
|
39
|
-
destination is a string URL to redirect or rewrite to, or null if no action is taken or "notfound"
|
|
40
|
-
*/
|
|
41
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
3
|
exports.multitenant = multitenant;
|
|
43
4
|
// Get the reserved paths from the overrides configuration
|