notherbase-fs 1.5.1 → 1.5.3
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/controllers/explorer.js +2 -8
- package/controllers/pages.js +13 -15
- package/controllers/the-front.js +22 -17
- package/notherbase-fs.js +7 -2
- package/package.json +1 -1
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/local-scripts/game.js +0 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/local-scripts/items.js +0 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/local-scripts/nono.js +0 -0
- package/test/explorer/coast/tall-beach/nono-cove/server-scripts/emailTime.js +11 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/server-scripts/getTimer.js +1 -1
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/styles/index.css +0 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/styles/items-floor.css +0 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/styles/nono.css +0 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/views/index.ejs +0 -0
- package/test/{coast → explorer/coast}/tall-beach/nono-cove/views/nono-og.ejs +0 -0
- package/test/test-index.js +1 -1
- package/test/the-front/server-scripts/emailTime.js +11 -0
- package/test/the-front/server-scripts/getTimer.js +31 -0
- package/test/{views → the-front/views}/check.ejs +0 -0
- package/test/{views → the-front/views}/index.ejs +14 -0
- package/test/void/index.ejs +1 -1
- package/test/coast/tall-beach/nono-cove/server-scripts/emailTime.js +0 -9
- package/test/coast/tall-beach/nono-cove/server-scripts/game.js +0 -31
package/controllers/explorer.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
-
import path from 'node:path';
|
|
3
2
|
import fs from 'fs';
|
|
4
|
-
import { nextTick } from "node:process";
|
|
5
3
|
|
|
6
4
|
let router = express.Router();
|
|
7
5
|
|
|
@@ -11,7 +9,8 @@ router.post(`/:region/:area/:poi/:detail/serve/:script`, async function(req, res
|
|
|
11
9
|
let currentRoute = `${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
|
|
12
10
|
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
13
11
|
|
|
14
|
-
let
|
|
12
|
+
let script = await import(`${req.worldDir}/${currentAreaRoute}/server-scripts/${req.params.script}.js`);
|
|
13
|
+
let scriptResult = await script.default(req.db, currentRoute, foundUser, req.body);
|
|
15
14
|
res.send({ scriptResult: scriptResult });
|
|
16
15
|
}
|
|
17
16
|
catch(err) {
|
|
@@ -148,9 +147,4 @@ router.get(`/:region/:area/:poi`, async function(req, res, next) {
|
|
|
148
147
|
}
|
|
149
148
|
});
|
|
150
149
|
|
|
151
|
-
// start location
|
|
152
|
-
router.get("/", function(req, res) {
|
|
153
|
-
res.redirect("/the-front");
|
|
154
|
-
});
|
|
155
|
-
|
|
156
150
|
export default router;
|
package/controllers/pages.js
CHANGED
|
@@ -6,7 +6,8 @@ router.post(`/serve/:script`, async function(req, res) {
|
|
|
6
6
|
try {
|
|
7
7
|
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
8
8
|
|
|
9
|
-
let
|
|
9
|
+
let script = await import(`${req.pagesDir}/scripts/${req.params.script}.js`);
|
|
10
|
+
let scriptResult = await script.default(req.db, foundUser, req.body);
|
|
10
11
|
res.send(scriptResult);
|
|
11
12
|
}
|
|
12
13
|
catch(err) {
|
|
@@ -16,20 +17,17 @@ router.post(`/serve/:script`, async function(req, res) {
|
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
router.get(`/:page`, async function(req, res, next) {
|
|
19
|
-
fs.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
next();
|
|
31
|
-
}
|
|
32
|
-
});
|
|
20
|
+
if (fs.existsSync(`${req.pagesDir}/${req.params.page}.ejs`)) {
|
|
21
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
22
|
+
|
|
23
|
+
res.render(`${req.pagesDir}/${req.params.page}.ejs`, {
|
|
24
|
+
user: foundUser,
|
|
25
|
+
query: req.query
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
next();
|
|
30
|
+
}
|
|
33
31
|
});
|
|
34
32
|
|
|
35
33
|
export default router;
|
package/controllers/the-front.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import express from "express";
|
|
2
2
|
let router = express.Router();
|
|
3
|
+
import fs from 'fs';
|
|
3
4
|
|
|
4
5
|
router.post(`/serve/:script`, async function(req, res) {
|
|
5
6
|
try {
|
|
6
|
-
let
|
|
7
|
+
let script = await import(`${req.frontDir}/server-scripts/${req.params.script}.js`);
|
|
8
|
+
let scriptResult = await script.default(req.db, "/the-front", req.session.currentUser, req.body);
|
|
7
9
|
res.send(scriptResult);
|
|
8
10
|
}
|
|
9
11
|
catch(err) {
|
|
@@ -12,24 +14,28 @@ router.post(`/serve/:script`, async function(req, res) {
|
|
|
12
14
|
}
|
|
13
15
|
});
|
|
14
16
|
|
|
15
|
-
router.get(`/:detail`, async function(req, res) {
|
|
17
|
+
router.get(`/:detail`, async function(req, res, next) {
|
|
16
18
|
try {
|
|
17
|
-
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
18
|
-
const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
19
|
-
|
|
20
19
|
let main = `${req.frontDir}/views/${req.params.detail}`;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
user:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
if (fs.existsSync(main + ".ejs")) {
|
|
22
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
23
|
+
const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
let context = {
|
|
27
|
+
siteTitle: `NotherBase - ${req.params.detail}`,
|
|
28
|
+
user: foundUser,
|
|
29
|
+
main: main,
|
|
30
|
+
inventory: foundInventory,
|
|
31
|
+
query: req.query,
|
|
32
|
+
dir: req.frontDir,
|
|
33
|
+
route: `/the-front/${req.params.detail}`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
res.render(`explorer`, context);
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
res.render(`explorer`, context);
|
|
38
|
+
else next();
|
|
33
39
|
}
|
|
34
40
|
catch(err) {
|
|
35
41
|
console.log(err);
|
|
@@ -39,11 +45,10 @@ router.get(`/:detail`, async function(req, res) {
|
|
|
39
45
|
|
|
40
46
|
router.get(`/`, async function(req, res) {
|
|
41
47
|
try {
|
|
48
|
+
let main = `${req.frontDir}/views/index`;
|
|
42
49
|
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
43
50
|
const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
44
51
|
|
|
45
|
-
let main = `${req.frontDir}/views/index`;
|
|
46
|
-
|
|
47
52
|
let context = {
|
|
48
53
|
siteTitle: `NotherBase - The Front`,
|
|
49
54
|
user: foundUser,
|
package/notherbase-fs.js
CHANGED
|
@@ -100,9 +100,14 @@ class NotherBaseFS {
|
|
|
100
100
|
|
|
101
101
|
this.app.use("/the-front", controllers.front);
|
|
102
102
|
|
|
103
|
-
this.app.use("/", controllers.authCheck, controllers.explorer);
|
|
104
|
-
|
|
105
103
|
this.app.use("/", controllers.pages);
|
|
104
|
+
|
|
105
|
+
this.app.use("/", controllers.authCheck, controllers.explorer);
|
|
106
|
+
|
|
107
|
+
// start location
|
|
108
|
+
this.app.get("/", function(req, res) {
|
|
109
|
+
res.redirect("/the-front");
|
|
110
|
+
});
|
|
106
111
|
|
|
107
112
|
this.app.use(controllers.void);
|
|
108
113
|
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/test/test-index.js
CHANGED
|
@@ -2,4 +2,4 @@ import NotherBaseFS from "../notherbase-fs.js";
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
const __dirname = fileURLToPath(new URL('./', import.meta.url));
|
|
4
4
|
|
|
5
|
-
const notherBaseFS = new NotherBaseFS(__dirname
|
|
5
|
+
const notherBaseFS = new NotherBaseFS(`${__dirname}explorer`, `${__dirname}void`, `${__dirname}the-front`, `${__dirname}pages`);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default async function getTimer(db, route, user, params) {
|
|
2
|
+
try {
|
|
3
|
+
let poi = await db.poi.findOne({ route: route, user: user });
|
|
4
|
+
|
|
5
|
+
let now = Date.now();
|
|
6
|
+
|
|
7
|
+
if (!poi.data) poi.data = {
|
|
8
|
+
timer: 0,
|
|
9
|
+
lastTime: now
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
if (!poi.data.lastTime) poi.data.lastTime = now;
|
|
13
|
+
if (!poi.data.timer) poi.data.timer = 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let difference = (now - poi.data.lastTime) / 1000;
|
|
17
|
+
|
|
18
|
+
poi.data.timer -= difference;
|
|
19
|
+
if (poi.data.timer < 0) poi.data.timer = 0;
|
|
20
|
+
poi.data.lastTime = now;
|
|
21
|
+
|
|
22
|
+
poi.markModified("data");
|
|
23
|
+
await poi.save();
|
|
24
|
+
|
|
25
|
+
return poi.data.timer;
|
|
26
|
+
}
|
|
27
|
+
catch(err) {
|
|
28
|
+
console.log(err);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
File without changes
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
<button onclick="addGold()">Gold</button>
|
|
6
6
|
|
|
7
|
+
<button onclick="emailTime()">email</button>
|
|
8
|
+
|
|
7
9
|
<hr>
|
|
8
10
|
|
|
9
11
|
<h3>Register Account</h3>
|
|
@@ -154,4 +156,16 @@
|
|
|
154
156
|
let addGold = function addGold(params) {
|
|
155
157
|
playerInventory.change(itemIDs[0], 2);
|
|
156
158
|
}
|
|
159
|
+
|
|
160
|
+
let time = 0;
|
|
161
|
+
|
|
162
|
+
let emailTime = async () => {
|
|
163
|
+
$.post("/coast/tall-beach/nono-cove/index/serve/emailTime", {
|
|
164
|
+
toEmail: "wyattsushi@gmail.com",
|
|
165
|
+
subject: "New Time Update!",
|
|
166
|
+
html: `New Time: ${time}`
|
|
167
|
+
}, (res) => {
|
|
168
|
+
console.log(res);
|
|
169
|
+
})
|
|
170
|
+
}
|
|
157
171
|
</script>
|
package/test/void/index.ejs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
<a href="/">Leave the Void</a>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const req = require("express/lib/request");
|
|
2
|
-
|
|
3
|
-
module.exports = async function gameServerScript(db) {
|
|
4
|
-
try {
|
|
5
|
-
let foundGame = await db.game.findOne({ name: "test" });
|
|
6
|
-
|
|
7
|
-
if (!foundGame) {
|
|
8
|
-
await db.game.create({
|
|
9
|
-
name: "test",
|
|
10
|
-
data: {
|
|
11
|
-
count: 0
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
let newCount = foundGame.data.count + 1;
|
|
19
|
-
foundGame.data = {
|
|
20
|
-
count: newCount
|
|
21
|
-
}
|
|
22
|
-
foundGame.markModified("data");
|
|
23
|
-
await foundGame.save();
|
|
24
|
-
|
|
25
|
-
return newCount;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch(err) {
|
|
29
|
-
console.log(err);
|
|
30
|
-
}
|
|
31
|
-
}
|