notherbase-fs 1.0.30 → 1.0.34
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/main.js +24 -17
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -3,53 +3,60 @@ const inventory = require(process.cwd() + "/models/inventory").inventory;
|
|
|
3
3
|
let router;
|
|
4
4
|
let dir;
|
|
5
5
|
|
|
6
|
-
let explore = function explore(route,
|
|
7
|
-
styles
|
|
6
|
+
let explore = function explore(route, options = {
|
|
7
|
+
styles: [],
|
|
8
|
+
scripts: [],
|
|
9
|
+
needsKey: "",
|
|
10
|
+
dropOff: ""
|
|
11
|
+
}) {
|
|
12
|
+
options.styles = options.styles.map(style => {
|
|
8
13
|
style = `${dir}/styles/${style}`;
|
|
9
14
|
return style;
|
|
10
15
|
});
|
|
11
16
|
|
|
12
|
-
scripts = scripts.map(script => {
|
|
17
|
+
options.scripts = options.scripts.map(script => {
|
|
13
18
|
script = `${dir}/local-scripts/${script}`;
|
|
14
19
|
return script;
|
|
15
20
|
});
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
if (route !== "") main = route;
|
|
19
|
-
main = `${dir}/views/${main}`;
|
|
22
|
+
options.main = "index";
|
|
23
|
+
if (route !== "") options.main = route;
|
|
24
|
+
options.main = `${dir}/views/${options.main}`;
|
|
20
25
|
|
|
21
26
|
router.get(`/${route}`, async function(req, res) {
|
|
22
27
|
try {
|
|
23
28
|
const foundInventory = await inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
24
29
|
|
|
25
|
-
if (needsKey !== "" && foundInventory) {
|
|
30
|
+
if (options.needsKey !== "" && foundInventory) {
|
|
26
31
|
let hasKey = false;
|
|
27
32
|
|
|
28
33
|
for (let i = 0; i < foundInventory.items.length; i++) {
|
|
29
|
-
if (foundInventory.items[i].item.name === needsKey) hasKey = true;
|
|
34
|
+
if (foundInventory.items[i].item.name === options.needsKey) hasKey = true;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
if (!hasKey) res.redirect(dropOff);
|
|
37
|
+
if (!hasKey) res.redirect(options.dropOff);
|
|
33
38
|
else res.render(`explorer`,
|
|
34
39
|
{
|
|
35
40
|
siteTitle: "NotherBase",
|
|
36
41
|
user: req.session.currentUserFull,
|
|
37
|
-
styles: styles,
|
|
38
|
-
main: main,
|
|
39
|
-
scripts: scripts,
|
|
42
|
+
styles: options.styles,
|
|
43
|
+
main: options.main,
|
|
44
|
+
scripts: options.scripts,
|
|
40
45
|
pov: req.query.pov,
|
|
41
|
-
inventory: foundInventory
|
|
46
|
+
inventory: foundInventory,
|
|
47
|
+
query: req.query
|
|
42
48
|
});
|
|
43
49
|
}
|
|
44
50
|
else res.render(`explorer`,
|
|
45
51
|
{
|
|
46
52
|
siteTitle: "NotherBase",
|
|
47
53
|
user: req.session.currentUserFull,
|
|
48
|
-
styles: styles,
|
|
49
|
-
main: main,
|
|
50
|
-
scripts: scripts,
|
|
54
|
+
styles: options.styles,
|
|
55
|
+
main: options.main,
|
|
56
|
+
scripts: options.scripts,
|
|
51
57
|
pov: req.query.pov,
|
|
52
|
-
inventory: foundInventory
|
|
58
|
+
inventory: foundInventory,
|
|
59
|
+
query: req.query
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
62
|
catch(err) {
|