Browse Source

v1.1.1: recursive routes/middlewares paths reading

CrazyDoctor 1 month ago
parent
commit
e0d2ddc6f7
4 changed files with 5 additions and 5 deletions
  1. 2 2
      dist/server/Server.js
  2. 0 0
      dist/server/Server.js.map
  3. 2 2
      lib/server/Server.ts
  4. 1 1
      package.json

+ 2 - 2
dist/server/Server.js

@@ -243,7 +243,7 @@ class Server {
     }
     }
     registerRoutes(dir) {
     registerRoutes(dir) {
         return __awaiter(this, void 0, void 0, function* () {
         return __awaiter(this, void 0, void 0, function* () {
-            const files = fs_1.default.readdirSync(dir);
+            const files = fs_1.default.readdirSync(dir, { recursive: true, encoding: 'utf8' });
             for (const file of files) {
             for (const file of files) {
                 if (/\.js$/.test(file)) {
                 if (/\.js$/.test(file)) {
                     const { default: RouteClass } = yield Promise.resolve(`${path_1.default.join(dir, file)}`).then(s => __importStar(require(s)));
                     const { default: RouteClass } = yield Promise.resolve(`${path_1.default.join(dir, file)}`).then(s => __importStar(require(s)));
@@ -259,7 +259,7 @@ class Server {
     }
     }
     registerMiddlewares(dir) {
     registerMiddlewares(dir) {
         return __awaiter(this, void 0, void 0, function* () {
         return __awaiter(this, void 0, void 0, function* () {
-            const files = fs_1.default.readdirSync(dir);
+            const files = fs_1.default.readdirSync(dir, { recursive: true, encoding: 'utf8' });
             for (const file of files) {
             for (const file of files) {
                 if (/\.js$/.test(file)) {
                 if (/\.js$/.test(file)) {
                     const { default: MiddlewareClass } = yield Promise.resolve(`${path_1.default.join(dir, file)}`).then(s => __importStar(require(s)));
                     const { default: MiddlewareClass } = yield Promise.resolve(`${path_1.default.join(dir, file)}`).then(s => __importStar(require(s)));

File diff suppressed because it is too large
+ 0 - 0
dist/server/Server.js.map


+ 2 - 2
lib/server/Server.ts

@@ -251,7 +251,7 @@ class Server {
 	}
 	}
 
 
 	public async registerRoutes(dir: string): Promise<Server> {
 	public async registerRoutes(dir: string): Promise<Server> {
-		const files = fs.readdirSync(dir);
+		const files = fs.readdirSync(dir, { recursive: true, encoding: 'utf8' });
 
 
 		for(const file of files) {
 		for(const file of files) {
 			if(/\.js$/.test(file)) {
 			if(/\.js$/.test(file)) {
@@ -265,7 +265,7 @@ class Server {
 	}
 	}
 
 
 	public async registerMiddlewares(dir: string): Promise<Server> {
 	public async registerMiddlewares(dir: string): Promise<Server> {
-		const files = fs.readdirSync(dir);
+		const files = fs.readdirSync(dir, { recursive: true, encoding: 'utf8' });
 
 
 		for(const file of files) {
 		for(const file of files) {
 			if(/\.js$/.test(file)) {
 			if(/\.js$/.test(file)) {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "org.crazydoctor.expressts",
   "name": "org.crazydoctor.expressts",
-  "version": "1.1.0",
+  "version": "1.1.1",
   "devDependencies": {
   "devDependencies": {
     "@types/express-session": "^1.17.7",
     "@types/express-session": "^1.17.7",
     "@types/node": "^20.4.9",
     "@types/node": "^20.4.9",

Some files were not shown because too many files changed in this diff