speedly 2.0.13 → 2.0.14
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/cjs/config/init.js
CHANGED
|
@@ -46,7 +46,9 @@ function speedly(config = {}) {
|
|
|
46
46
|
app.get("/", (req, res) => {
|
|
47
47
|
res.send(`<h1>Welcome to ${require(path_1.default.join(process.cwd(), "package.json")).name} App</h1>
|
|
48
48
|
<p>Your app is running successfully.</p>
|
|
49
|
-
|
|
49
|
+
${finalConfig.documentation
|
|
50
|
+
? '<p>Visit <a href="/docs">/docs</a> for API documentation.</p>'
|
|
51
|
+
: ""}`);
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
// user can call this manually if needed
|
|
@@ -189,12 +189,32 @@ function routeAnalyzer(route, routerName) {
|
|
|
189
189
|
return routerDetails;
|
|
190
190
|
}
|
|
191
191
|
/* =================== LOAD MODULES ==================== */
|
|
192
|
+
function findRoutersInDir(dir) {
|
|
193
|
+
const entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
194
|
+
const routers = [];
|
|
195
|
+
for (const entry of entries) {
|
|
196
|
+
const fullPath = path_1.default.join(dir, entry.name);
|
|
197
|
+
if (entry.isDirectory()) {
|
|
198
|
+
routers.push(...findRoutersInDir(fullPath));
|
|
199
|
+
}
|
|
200
|
+
else if (entry.isFile() &&
|
|
201
|
+
entry.name.match(/\.route(rs|r|s)?\.(js|ts)$/)) {
|
|
202
|
+
try {
|
|
203
|
+
if (require(fullPath)) {
|
|
204
|
+
routers.push(fullPath);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (err) { }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return routers;
|
|
211
|
+
}
|
|
192
212
|
function RouterFetcher(baseDir) {
|
|
193
|
-
const modules =
|
|
213
|
+
const modules = findRoutersInDir(baseDir);
|
|
194
214
|
let paths = {};
|
|
195
215
|
const tags = [];
|
|
196
216
|
modules.forEach((mf) => {
|
|
197
|
-
const routerPath =
|
|
217
|
+
const routerPath = mf;
|
|
198
218
|
try {
|
|
199
219
|
const router = require(routerPath);
|
|
200
220
|
paths = { ...paths, ...routeAnalyzer(router, mf) };
|
package/dist/esm/config/init.js
CHANGED
|
@@ -46,7 +46,9 @@ function speedly(config = {}) {
|
|
|
46
46
|
app.get("/", (req, res) => {
|
|
47
47
|
res.send(`<h1>Welcome to ${require(path_1.default.join(process.cwd(), "package.json")).name} App</h1>
|
|
48
48
|
<p>Your app is running successfully.</p>
|
|
49
|
-
|
|
49
|
+
${finalConfig.documentation
|
|
50
|
+
? '<p>Visit <a href="/docs">/docs</a> for API documentation.</p>'
|
|
51
|
+
: ""}`);
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
// user can call this manually if needed
|
|
@@ -189,12 +189,32 @@ function routeAnalyzer(route, routerName) {
|
|
|
189
189
|
return routerDetails;
|
|
190
190
|
}
|
|
191
191
|
/* =================== LOAD MODULES ==================== */
|
|
192
|
+
function findRoutersInDir(dir) {
|
|
193
|
+
const entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
194
|
+
const routers = [];
|
|
195
|
+
for (const entry of entries) {
|
|
196
|
+
const fullPath = path_1.default.join(dir, entry.name);
|
|
197
|
+
if (entry.isDirectory()) {
|
|
198
|
+
routers.push(...findRoutersInDir(fullPath));
|
|
199
|
+
}
|
|
200
|
+
else if (entry.isFile() &&
|
|
201
|
+
entry.name.match(/\.route(rs|r|s)?\.(js|ts)$/)) {
|
|
202
|
+
try {
|
|
203
|
+
if (require(fullPath)) {
|
|
204
|
+
routers.push(fullPath);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (err) { }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return routers;
|
|
211
|
+
}
|
|
192
212
|
function RouterFetcher(baseDir) {
|
|
193
|
-
const modules =
|
|
213
|
+
const modules = findRoutersInDir(baseDir);
|
|
194
214
|
let paths = {};
|
|
195
215
|
const tags = [];
|
|
196
216
|
modules.forEach((mf) => {
|
|
197
|
-
const routerPath =
|
|
217
|
+
const routerPath = mf;
|
|
198
218
|
try {
|
|
199
219
|
const router = require(routerPath);
|
|
200
220
|
paths = { ...paths, ...routeAnalyzer(router, mf) };
|