notherbase-fs 1.5.0 → 1.5.2
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 +14 -15
- package/controllers/the-front.js +22 -17
- package/controllers/user.js +1 -1
- package/notherbase-fs.js +5 -0
- package/package.json +1 -1
- package/public/js/chat-box.js +8 -0
- package/public/styles/chat.css +13 -16
- 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 -3
- 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,18 @@ 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
|
-
|
|
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
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
next();
|
|
31
|
+
}
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
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/controllers/user.js
CHANGED
|
@@ -71,7 +71,7 @@ router.post("/logout", authCheck, async function(req, res) {
|
|
|
71
71
|
|
|
72
72
|
router.get("/all", async function(req, res) {
|
|
73
73
|
try {
|
|
74
|
-
let foundUsers = await user.find({}, 'username coin home authLevels location attributes');
|
|
74
|
+
let foundUsers = await user.find({}, 'username coin home authLevels location attributes email');
|
|
75
75
|
|
|
76
76
|
res.status(200).send({ foundUsers: foundUsers });
|
|
77
77
|
}
|
package/notherbase-fs.js
CHANGED
|
@@ -104,6 +104,11 @@ class NotherBaseFS {
|
|
|
104
104
|
|
|
105
105
|
this.app.use("/", controllers.pages);
|
|
106
106
|
|
|
107
|
+
// start location
|
|
108
|
+
this.app.get("/", function(req, res) {
|
|
109
|
+
res.redirect("/the-front");
|
|
110
|
+
});
|
|
111
|
+
|
|
107
112
|
this.app.use(controllers.void);
|
|
108
113
|
|
|
109
114
|
this.server.listen(process.env.PORT, function () {
|
package/package.json
CHANGED
package/public/js/chat-box.js
CHANGED
|
@@ -6,6 +6,7 @@ class ChatBox {
|
|
|
6
6
|
this.$div = $(`.chat-box#${room}`);
|
|
7
7
|
this.$chatLog = null;
|
|
8
8
|
this.$entry = null;
|
|
9
|
+
this.maxMessages = 100;
|
|
9
10
|
|
|
10
11
|
this.socket = io({
|
|
11
12
|
query: {
|
|
@@ -21,6 +22,13 @@ class ChatBox {
|
|
|
21
22
|
newMessage = (msg) => {
|
|
22
23
|
let time = new Date(msg.time);
|
|
23
24
|
this.$chatLog.append(`<p>[${time.toLocaleTimeString('en-US')}] ${msg.name}: ${msg.text}</p>`);
|
|
25
|
+
this.$chatLog.scrollTop(this.$chatLog.prop("scrollHeight"));
|
|
26
|
+
let msgs = this.$chatLog.find("p");
|
|
27
|
+
if (msgs.length > this.maxMessages) {
|
|
28
|
+
for (let i = 0; i < msgs.length - this.maxMessages; i++) {
|
|
29
|
+
msgs[i].remove();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
sendMessage = () => {
|
package/public/styles/chat.css
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
.chat-box {
|
|
2
2
|
position: relative;
|
|
3
|
-
box-shadow:
|
|
4
|
-
margin-top: 20px;
|
|
3
|
+
box-shadow: var(--boxShadow);
|
|
5
4
|
width: 100%;
|
|
6
|
-
|
|
5
|
+
height: 400px;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
.chat-name {
|
|
@@ -13,24 +12,23 @@
|
|
|
13
12
|
|
|
14
13
|
.chat-log {
|
|
15
14
|
width: 100%;
|
|
16
|
-
height:
|
|
15
|
+
height: 300px;
|
|
17
16
|
background-color: rgba(0, 0, 0, 0.534);
|
|
18
17
|
overflow: auto;
|
|
19
18
|
padding: 5px;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
.chat-send {
|
|
23
|
-
|
|
24
|
-
right: 0;
|
|
25
|
-
bottom: 0;
|
|
26
|
-
height: 25px;
|
|
22
|
+
height: calc(var(--pSize) + 2 * var(--padding));
|
|
27
23
|
width: 5em;
|
|
28
24
|
outline: none;
|
|
29
25
|
background-color: var(--bgColor);
|
|
30
|
-
border:
|
|
26
|
+
border: var(--standardBorder);
|
|
31
27
|
color: var(--textColor);
|
|
32
28
|
text-align: center;
|
|
33
|
-
padding:
|
|
29
|
+
padding: 0;
|
|
30
|
+
margin: 0;
|
|
31
|
+
border-radius: 0;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
.chat-send:hover {
|
|
@@ -40,21 +38,20 @@
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
.chat-entry {
|
|
43
|
-
|
|
44
|
-
left: 0;
|
|
45
|
-
bottom: 0;
|
|
46
|
-
height: 25px;
|
|
41
|
+
height: calc(var(--pSize) + 2 * var(--padding));
|
|
47
42
|
width: calc(100% - 5em);
|
|
48
43
|
outline: none;
|
|
49
44
|
background-color: var(--bgColor);
|
|
50
|
-
border:
|
|
45
|
+
border: var(--standardBorder);
|
|
51
46
|
color: var(--textColor);
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: var(--padding);
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
.chat-log > p {
|
|
55
52
|
color: var(--textColor);
|
|
56
53
|
margin: 0;
|
|
57
|
-
padding:
|
|
54
|
+
padding: 2px;
|
|
58
55
|
line-height: 1em;
|
|
59
56
|
text-align: left;
|
|
60
57
|
}
|
|
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
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
1
|
import NotherBaseFS from "../notherbase-fs.js";
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
4
3
|
const __dirname = fileURLToPath(new URL('./', import.meta.url));
|
|
5
|
-
console.log(__dirname);
|
|
6
4
|
|
|
7
|
-
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
|
-
}
|