webfast 0.1.37 → 0.1.38
Sign up to get free protection for your applications and to get access to all the features.
- package/example/content/js/test.js +2 -0
- package/example.js +3 -1
- package/modules/express/init.js +37 -4
- package/package.json +1 -1
package/example.js
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
const path = require(`path`);
|
2
|
+
const contentPath = path.join(__dirname,`example`,`content`)
|
2
3
|
let program = require(path.join(__dirname,`index.js`))({
|
3
4
|
wget : '/usr/local/bin/wget',
|
4
5
|
process : {
|
5
6
|
ts : Date.now()
|
6
|
-
}
|
7
|
+
},
|
8
|
+
contentPath : contentPath
|
7
9
|
});
|
8
10
|
console.log(`Required`);
|
package/modules/express/init.js
CHANGED
@@ -139,12 +139,18 @@ module.exports = async function (program) {
|
|
139
139
|
|
140
140
|
// Check if minify at the end
|
141
141
|
const fileName = req.params.file;
|
142
|
-
const
|
142
|
+
const isExtend = /-extend\.js$/.test(fileName);
|
143
143
|
|
144
|
-
if
|
145
|
-
|
146
|
-
|
144
|
+
// Check if extending
|
145
|
+
if (isExtend) {
|
146
|
+
console.log(`${fileName} ends with -extend.js`);
|
147
|
+
// IS extended file include loading in
|
148
|
+
|
149
|
+
const toRequestFile = req.params.file.replace(`-extend.js`, `.js`);
|
147
150
|
contentFolder = program.path.join(__dirname, `..`, `..`, `app`, `content`, req.params.type, toRequestFile);
|
151
|
+
// check if file exists in process, if not make it before giving out
|
152
|
+
// Check i
|
153
|
+
console.log(`Content Folder`);
|
148
154
|
} else {
|
149
155
|
console.log(`${fileName} does not end with -min.js`);
|
150
156
|
}
|
@@ -156,6 +162,33 @@ module.exports = async function (program) {
|
|
156
162
|
}
|
157
163
|
})
|
158
164
|
|
165
|
+
// Walkt through for paths to be open
|
166
|
+
if (program.set.contentPath != undefined) {
|
167
|
+
// Loop Through
|
168
|
+
const readDir = program.fs.readdirSync(program.set.contentPath);
|
169
|
+
|
170
|
+
// Create request app path for it
|
171
|
+
//loop through
|
172
|
+
for (let rdi in readDir) {
|
173
|
+
// Loop
|
174
|
+
const dirItem = readDir[rdi];
|
175
|
+
const dirPath = program.path.join(program.set.contentPath,dirItem);
|
176
|
+
// Now read the dir
|
177
|
+
// Create app.get
|
178
|
+
try {
|
179
|
+
const theRoute = `/inc/${dirItem}/*`;
|
180
|
+
app.get(theRoute, async (req, res) => {
|
181
|
+
const params = req.params;
|
182
|
+
console.log(`The Route is there`, theRoute);
|
183
|
+
});
|
184
|
+
|
185
|
+
} catch (err) {
|
186
|
+
console.error(`Errro for path read dir including something`, diritem);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
console.log(`We have directory`);
|
190
|
+
}
|
191
|
+
|
159
192
|
app.listen(port, () => {
|
160
193
|
console.log(`Server Listening`, port, basePath);
|
161
194
|
});
|