import routes recursive
This commit is contained in:
		@@ -11,14 +11,11 @@ export default class Router {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  async importRoutesFromPath(p, tpl = false) {
 | 
			
		||||
    await Promise.all(
 | 
			
		||||
      fs.readdirSync(path.resolve() + "/" + p)
 | 
			
		||||
        .filter(r => r.endsWith(".mjs"))
 | 
			
		||||
        .map(async r => {
 | 
			
		||||
          const tmp = (await import(`${path.resolve()}/${p}/${r}`)).default(this, tpl);
 | 
			
		||||
          this.use(tmp);
 | 
			
		||||
        })
 | 
			
		||||
    );
 | 
			
		||||
    for(let tmp of await fs.promises.readdir(path.resolve() + '/' + p, { withFileTypes: true }))
 | 
			
		||||
      if(tmp.isFile() && tmp.name.endsWith('.mjs'))
 | 
			
		||||
        this.use((await import(`${path.resolve()}/${p}/${tmp.name}`)).default(this, tpl));
 | 
			
		||||
      else if(tmp.isDirectory())
 | 
			
		||||
        await this.importRoutesFromPath(p + '/' + tmp.name);
 | 
			
		||||
    return this;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user