@stacksjs/router 0.58.72 → 0.58.73
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/dist/index.js +30 -10
- package/package.json +1 -1
- package/src/router.ts +16 -0
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// ../../../../node_modules/slugify/slugify.js
|
|
21
21
|
var require_slugify = __commonJS((exports, module) => {
|
|
22
22
|
(function(name, root, factory) {
|
|
23
23
|
if (typeof exports === "object") {
|
|
@@ -68,7 +68,7 @@ var require_slugify = __commonJS((exports, module) => {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
//
|
|
71
|
+
// ../../../../node_modules/pluralize/pluralize.js
|
|
72
72
|
var require_pluralize = __commonJS((exports, module) => {
|
|
73
73
|
(function(root, pluralize) {
|
|
74
74
|
if (typeof import.meta.require === "function" && typeof exports === "object" && typeof module === "object") {
|
|
@@ -395,10 +395,11 @@ var require_pluralize = __commonJS((exports, module) => {
|
|
|
395
395
|
});
|
|
396
396
|
});
|
|
397
397
|
|
|
398
|
-
//
|
|
398
|
+
// ../path/src/index.ts
|
|
399
399
|
import process2 from "process";
|
|
400
|
+
import os from "os";
|
|
400
401
|
|
|
401
|
-
//
|
|
402
|
+
// ../../../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
402
403
|
var normalizeWindowsPath = function(input = "") {
|
|
403
404
|
if (!input) {
|
|
404
405
|
return input;
|
|
@@ -599,7 +600,7 @@ var parse = function(p) {
|
|
|
599
600
|
name: base.slice(0, base.length - extension.length)
|
|
600
601
|
};
|
|
601
602
|
};
|
|
602
|
-
//
|
|
603
|
+
// ../path/src/index.ts
|
|
603
604
|
function actionsPath(path2) {
|
|
604
605
|
return corePath(`actions/src/${path2 || ""}`);
|
|
605
606
|
}
|
|
@@ -838,7 +839,10 @@ function queuePath(path2) {
|
|
|
838
839
|
function realtimePath(path2) {
|
|
839
840
|
return corePath(`realtime/${path2 || ""}`);
|
|
840
841
|
}
|
|
841
|
-
function resourcesPath(path2) {
|
|
842
|
+
function resourcesPath(path2, options) {
|
|
843
|
+
const absolutePath = projectStoragePath(`resources/${path2 || ""}`);
|
|
844
|
+
if (options?.relative)
|
|
845
|
+
return relative(process2.cwd(), absolutePath);
|
|
842
846
|
return projectPath(`resources/${path2 || ""}`);
|
|
843
847
|
}
|
|
844
848
|
function replPath(path2) {
|
|
@@ -892,6 +896,9 @@ function serverlessPath(path2) {
|
|
|
892
896
|
function stacksPath(path2) {
|
|
893
897
|
return frameworkPath(`src/${path2 || ""}`);
|
|
894
898
|
}
|
|
899
|
+
function shellPath(path2) {
|
|
900
|
+
return corePath(`shell/${path2 || ""}`);
|
|
901
|
+
}
|
|
895
902
|
function stringsPath(path2) {
|
|
896
903
|
return corePath(`strings/${path2 || ""}`);
|
|
897
904
|
}
|
|
@@ -922,6 +929,9 @@ function vitePath(path2) {
|
|
|
922
929
|
function xRayPath(path2) {
|
|
923
930
|
return frameworkPath(`stacks/x-ray/${path2 || ""}`);
|
|
924
931
|
}
|
|
932
|
+
function homeDir(path2) {
|
|
933
|
+
return os.homedir() + (path2 ? (path2.startsWith("/") ? "" : "/") + path2 : "~");
|
|
934
|
+
}
|
|
925
935
|
var path2 = {
|
|
926
936
|
actionsPath,
|
|
927
937
|
userActionsPath,
|
|
@@ -1008,6 +1018,7 @@ var path2 = {
|
|
|
1008
1018
|
serverlessPath,
|
|
1009
1019
|
stacksPath,
|
|
1010
1020
|
stringsPath,
|
|
1021
|
+
shellPath,
|
|
1011
1022
|
storesPath,
|
|
1012
1023
|
testingPath,
|
|
1013
1024
|
testsPath,
|
|
@@ -1024,6 +1035,7 @@ var path2 = {
|
|
|
1024
1035
|
validationPath,
|
|
1025
1036
|
vitePath,
|
|
1026
1037
|
xRayPath,
|
|
1038
|
+
homeDir,
|
|
1027
1039
|
basename,
|
|
1028
1040
|
delimiter,
|
|
1029
1041
|
dirname,
|
|
@@ -1199,9 +1211,9 @@ var isObject = function(val) {
|
|
|
1199
1211
|
// src/router.ts
|
|
1200
1212
|
import {log as log2} from "@stacksjs/logging";
|
|
1201
1213
|
|
|
1202
|
-
//
|
|
1214
|
+
// ../strings/src/utils.ts
|
|
1203
1215
|
var import_slugify = __toESM(require_slugify(), 1);
|
|
1204
|
-
//
|
|
1216
|
+
// ../../../../node_modules/change-case/dist/index.js
|
|
1205
1217
|
function split(value) {
|
|
1206
1218
|
let result = value.trim();
|
|
1207
1219
|
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
@@ -1282,7 +1294,7 @@ var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
|
1282
1294
|
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
1283
1295
|
var SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
1284
1296
|
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
1285
|
-
//
|
|
1297
|
+
// ../../../../node_modules/title-case/dist/index.js
|
|
1286
1298
|
var WORD_SEPARATORS = new Set(["\u2014", "\u2013", "-", "\u2015", "/"]);
|
|
1287
1299
|
var SENTENCE_TERMINATORS = new Set([".", "!", "?"]);
|
|
1288
1300
|
var TITLE_TERMINATORS = new Set([
|
|
@@ -1330,7 +1342,7 @@ var SMALL_WORDS = new Set([
|
|
|
1330
1342
|
"without",
|
|
1331
1343
|
"yet"
|
|
1332
1344
|
]);
|
|
1333
|
-
//
|
|
1345
|
+
// ../strings/src/pluralize.ts
|
|
1334
1346
|
var pluralize = __toESM(require_pluralize(), 1);
|
|
1335
1347
|
// src/router.ts
|
|
1336
1348
|
class Router {
|
|
@@ -1370,6 +1382,14 @@ class Router {
|
|
|
1370
1382
|
log2.debug(`Prepared URI: ${uri}`);
|
|
1371
1383
|
return this.addRoute("GET", uri, callback, 200);
|
|
1372
1384
|
}
|
|
1385
|
+
async email(path5) {
|
|
1386
|
+
path5 = pascalCase(path5);
|
|
1387
|
+
const emailModule = await import(path2.userNotificationsPath(`${path5}.ts`));
|
|
1388
|
+
const callback = emailModule.default.handle;
|
|
1389
|
+
const uri = this.prepareUri(path5);
|
|
1390
|
+
this.addRoute("GET", uri, callback, 200);
|
|
1391
|
+
return this;
|
|
1392
|
+
}
|
|
1373
1393
|
async health() {
|
|
1374
1394
|
const healthModule = await import(path2.userActionsPath("HealthAction.ts"));
|
|
1375
1395
|
const callback = healthModule.default.handle;
|
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface RouterInterface {
|
|
|
13
13
|
delete: (url: Route['url'], callback: Route['callback']) => this
|
|
14
14
|
patch: (url: Route['url'], callback: Route['callback']) => this
|
|
15
15
|
put: (url: Route['url'], callback: Route['callback']) => this
|
|
16
|
+
email: (url: Route['url']) => Promise<this>
|
|
17
|
+
health: () => Promise<this>
|
|
18
|
+
job: (url: Route['url']) => Promise<this>
|
|
19
|
+
action: (url: Route['url']) => Promise<this>
|
|
16
20
|
group: (options: Prefix | RouteGroupOptions, callback: () => void) => this
|
|
17
21
|
name: (name: string) => this
|
|
18
22
|
middleware: (middleware: Route['middleware']) => this
|
|
@@ -69,6 +73,18 @@ export class Router implements RouterInterface {
|
|
|
69
73
|
return this.addRoute('GET', uri, callback, 200)
|
|
70
74
|
}
|
|
71
75
|
|
|
76
|
+
public async email(path: Route['url']): Promise<this> {
|
|
77
|
+
path = pascalCase(path)
|
|
78
|
+
|
|
79
|
+
const emailModule = await import(p.userNotificationsPath(`${path}.ts`))
|
|
80
|
+
const callback = emailModule.default.handle
|
|
81
|
+
|
|
82
|
+
const uri = this.prepareUri(path)
|
|
83
|
+
this.addRoute('GET', uri, callback, 200)
|
|
84
|
+
|
|
85
|
+
return this
|
|
86
|
+
}
|
|
87
|
+
|
|
72
88
|
public async health(): Promise<this> {
|
|
73
89
|
const healthModule = await import(p.userActionsPath('HealthAction.ts'))
|
|
74
90
|
const callback = healthModule.default.handle
|