diesel-core 1.0.27 → 1.0.29
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/main.js +16 -3
- package/dist/routes/hello.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -740,8 +740,6 @@ var q = g;
|
|
|
740
740
|
|
|
741
741
|
// src/main.ts
|
|
742
742
|
var { default: fs} = (() => ({}));
|
|
743
|
-
var __dirname = "/home/pradeep/Desktop/diesel/src";
|
|
744
|
-
|
|
745
743
|
class Diesel {
|
|
746
744
|
tempRoutes;
|
|
747
745
|
globalMiddlewares;
|
|
@@ -889,20 +887,26 @@ class Diesel {
|
|
|
889
887
|
break;
|
|
890
888
|
}
|
|
891
889
|
}
|
|
892
|
-
const
|
|
890
|
+
const projectRoot = process.cwd();
|
|
891
|
+
console.log("project root:-> ", projectRoot);
|
|
892
|
+
const routesPath = q.join(projectRoot, "src", "routes");
|
|
893
893
|
if (fs?.existsSync(routesPath)) {
|
|
894
|
+
console.log("calling loadroutes");
|
|
894
895
|
this.loadRoutes(routesPath, "");
|
|
895
896
|
}
|
|
897
|
+
console.log("routesPath", routesPath);
|
|
896
898
|
setTimeout(() => {
|
|
897
899
|
this.tempRoutes = null;
|
|
898
900
|
}, 2000);
|
|
899
901
|
}
|
|
900
902
|
async registerFileRoutes(filePath, baseRoute) {
|
|
903
|
+
console.log("registering file routes");
|
|
901
904
|
const module = await import(filePath);
|
|
902
905
|
let routePath = baseRoute + "/" + q.basename(filePath, ".ts");
|
|
903
906
|
if (routePath.endsWith("/index")) {
|
|
904
907
|
routePath = baseRoute;
|
|
905
908
|
}
|
|
909
|
+
console.log("routePath", routePath);
|
|
906
910
|
const supportedMethods = [
|
|
907
911
|
"GET",
|
|
908
912
|
"POST",
|
|
@@ -914,18 +918,27 @@ class Diesel {
|
|
|
914
918
|
"OPTIONS",
|
|
915
919
|
"PROPFIND"
|
|
916
920
|
];
|
|
921
|
+
console.log("module", module);
|
|
917
922
|
for (const method of supportedMethods) {
|
|
923
|
+
console.log("method", method);
|
|
918
924
|
if (module[method]) {
|
|
919
925
|
const lowerMethod = method;
|
|
920
926
|
const handler = module[method];
|
|
927
|
+
console.log("handler", handler);
|
|
921
928
|
this.trie.insert(routePath, { handler, method: lowerMethod });
|
|
929
|
+
console.log("inserted route", routePath, lowerMethod, "with handler", handler);
|
|
922
930
|
}
|
|
923
931
|
}
|
|
924
932
|
}
|
|
925
933
|
async loadRoutes(dirPath, baseRoute) {
|
|
934
|
+
console.log(`
|
|
935
|
+
called
|
|
936
|
+
`);
|
|
926
937
|
const files = await fs.promises.readdir(dirPath);
|
|
927
938
|
for (const file of files) {
|
|
939
|
+
console.log("does file exist?", file);
|
|
928
940
|
const filePath = q.join(dirPath, file);
|
|
941
|
+
console.log("file path", filePath);
|
|
929
942
|
const stat = await fs.promises.stat(filePath);
|
|
930
943
|
if (stat.isDirectory()) {
|
|
931
944
|
this.loadRoutes(filePath, baseRoute + "/" + file);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GET: (ctx: any) => any;
|