notherbase-fs 1.4.4 → 1.5.1
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/authCheck.js +2 -2
- package/controllers/contact.js +3 -3
- package/controllers/explorer.js +139 -172
- package/controllers/game.js +3 -4
- package/controllers/index.js +10 -12
- package/controllers/inventory.js +4 -5
- package/controllers/item.js +3 -4
- package/controllers/pages.js +29 -32
- package/controllers/the-front.js +62 -68
- package/controllers/user.js +6 -7
- package/controllers/void.js +16 -0
- package/models/chat.js +4 -4
- package/models/contact.js +4 -7
- package/models/detail.js +4 -7
- package/models/game.js +4 -7
- package/models/index.js +40 -11
- package/models/inventory.js +4 -7
- package/models/item.js +4 -7
- package/models/page.js +4 -4
- package/models/send-mail.js +3 -5
- package/models/user.js +3 -4
- package/notherbase-fs.js +101 -76
- package/package.json +8 -3
- package/public/js/chat-box.js +39 -25
- package/public/styles/chat.css +13 -16
- package/test/coast/tall-beach/nono-cove/views/index.ejs +11 -8
- package/test/test-index.js +4 -3
- package/views/explorer.ejs +1 -0
- package/controllers/chat.js +0 -28
- package/controllers/portfolio/models/projects.js +0 -16
- package/controllers/portfolio/views/index.ejs +0 -234
- package/controllers/portfolio/views/parts/tamago.ejs +0 -534
- package/models/start-mongoose.js +0 -36
package/controllers/authCheck.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { connectionSuccess } from "../models/index.js";
|
|
2
2
|
|
|
3
3
|
const authCheck = async function authCheck(req, res, next){
|
|
4
4
|
if (connectionSuccess) {
|
|
@@ -15,4 +15,4 @@ const authCheck = async function authCheck(req, res, next){
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
export default authCheck;
|
package/controllers/contact.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import express from "express";
|
|
2
2
|
const router = express.Router();
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import contact from "../models/contact.js";
|
|
5
5
|
|
|
6
6
|
router.post("/", async function(req, res) {
|
|
7
7
|
try {
|
|
@@ -19,4 +19,4 @@ router.post("/", async function(req, res) {
|
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
export default router;
|
package/controllers/explorer.js
CHANGED
|
@@ -1,189 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let router = require("express").Router();
|
|
6
|
-
|
|
7
|
-
const explorer = async function explorer(worldPath, voidPath) {
|
|
8
|
-
router.post(`/:region/:area/:poi/:detail/serve/:script`, async function(req, res) {
|
|
9
|
-
try {
|
|
10
|
-
let currentAreaRoute = `${req.params.region}/${req.params.area}/${req.params.poi}`;
|
|
11
|
-
let currentRoute = `${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
|
|
12
|
-
const foundUser = await db.user.findById(req.session.currentUser);
|
|
13
|
-
|
|
14
|
-
let scriptResult = await require(`${worldPath}/${currentAreaRoute}/server-scripts/${req.params.script}.js`)(db, currentRoute, foundUser, req.body);
|
|
15
|
-
res.send({ scriptResult: scriptResult });
|
|
16
|
-
}
|
|
17
|
-
catch(err) {
|
|
18
|
-
console.log(err);
|
|
19
|
-
res.status(500).end();
|
|
20
|
-
}
|
|
21
|
-
});
|
|
1
|
+
import express from "express";
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { nextTick } from "node:process";
|
|
22
5
|
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
let exists = await db.detail.exists({
|
|
26
|
-
route: req.query.route,
|
|
27
|
-
service: req.query.service,
|
|
28
|
-
scope: "local",
|
|
29
|
-
user: req.session.currentUser
|
|
30
|
-
});
|
|
6
|
+
let router = express.Router();
|
|
31
7
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
8
|
+
router.post(`/:region/:area/:poi/:detail/serve/:script`, async function(req, res) {
|
|
9
|
+
try {
|
|
10
|
+
let currentAreaRoute = `${req.params.region}/${req.params.area}/${req.params.poi}`;
|
|
11
|
+
let currentRoute = `${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
|
|
12
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
13
|
+
|
|
14
|
+
let scriptResult = await require(`${req.worldDir}/${currentAreaRoute}/server-scripts/${req.params.script}.js`)(db, currentRoute, foundUser, req.body);
|
|
15
|
+
res.send({ scriptResult: scriptResult });
|
|
16
|
+
}
|
|
17
|
+
catch(err) {
|
|
18
|
+
console.log(err);
|
|
19
|
+
res.status(500).end();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
router.get(`/recall`, async function(req, res) {
|
|
24
|
+
try {
|
|
25
|
+
let exists = await req.db.detail.exists({
|
|
26
|
+
route: req.query.route,
|
|
27
|
+
service: req.query.service,
|
|
28
|
+
scope: "local",
|
|
29
|
+
user: req.session.currentUser
|
|
30
|
+
});
|
|
42
31
|
|
|
43
|
-
|
|
32
|
+
if (!exists) {
|
|
33
|
+
await req.db.detail.create({
|
|
34
|
+
_lastUpdate: Date.now(),
|
|
44
35
|
route: req.query.route,
|
|
45
36
|
service: req.query.service,
|
|
46
37
|
scope: "local",
|
|
47
|
-
user: req.session.currentUser
|
|
38
|
+
user: req.session.currentUser,
|
|
39
|
+
data: {}
|
|
48
40
|
});
|
|
41
|
+
}
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
let found = await req.db.detail.findOne({
|
|
44
|
+
route: req.query.route,
|
|
45
|
+
service: req.query.service,
|
|
46
|
+
scope: "local",
|
|
47
|
+
user: req.session.currentUser
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (new Date(found._lastUpdate) > new Date(req.query._lastUpdate)) {
|
|
51
|
+
res.send({
|
|
52
|
+
isUpToDate: false,
|
|
53
|
+
data: found.data
|
|
59
54
|
});
|
|
60
55
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
56
|
+
else res.send({
|
|
57
|
+
isUpToDate: true,
|
|
58
|
+
data: null
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch(err) {
|
|
62
|
+
console.log(err);
|
|
63
|
+
res.status(500).end();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
router.post(`/commit`, async function(req, res) {
|
|
68
|
+
try {
|
|
69
|
+
await req.db.detail.updateOne({
|
|
70
|
+
route: req.body.route,
|
|
71
|
+
service: req.body.service,
|
|
72
|
+
scope: "local",
|
|
73
|
+
user: req.session.currentUser
|
|
74
|
+
}, {
|
|
75
|
+
route: req.body.route,
|
|
76
|
+
service: req.body.service,
|
|
77
|
+
scope: "local",
|
|
78
|
+
user: req.session.currentUser,
|
|
79
|
+
_lastUpdate: req.body.time,
|
|
80
|
+
data: req.body.data
|
|
81
|
+
}, {
|
|
82
|
+
upsert: true
|
|
83
|
+
});
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
await res.render(`explorer`, context);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
res.render(`explorer`,
|
|
116
|
-
{
|
|
117
|
-
siteTitle: "NotherBase | The Void",
|
|
118
|
-
user: null,
|
|
119
|
-
inventory: null,
|
|
120
|
-
main: `${voidPath}/index`,
|
|
121
|
-
route: `/void`
|
|
122
|
-
});
|
|
85
|
+
res.send("Update successful!");
|
|
86
|
+
}
|
|
87
|
+
catch(err) {
|
|
88
|
+
console.log(err);
|
|
89
|
+
res.status(500).end();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
router.get(`/:region/:area/:poi/:detail`, async function(req, res, next) {
|
|
94
|
+
try {
|
|
95
|
+
let main = `${req.worldDir}/${req.params.region}/${req.params.area}/${req.params.poi}/views/${req.params.detail}`;
|
|
96
|
+
|
|
97
|
+
if (fs.existsSync(main + ".ejs")) {
|
|
98
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
99
|
+
const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
100
|
+
|
|
101
|
+
let context = {
|
|
102
|
+
siteTitle: `NotherBase - ${req.params.detail}`,
|
|
103
|
+
user: foundUser,
|
|
104
|
+
main: main,
|
|
105
|
+
pov: req.query.pov,
|
|
106
|
+
inventory: foundInventory,
|
|
107
|
+
query: req.query,
|
|
108
|
+
dir: req.worldDir,
|
|
109
|
+
route: `/${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`
|
|
123
110
|
}
|
|
124
|
-
}
|
|
125
|
-
catch(err) {
|
|
126
|
-
console.log(err);
|
|
127
|
-
res.status(500).end();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
router.get(`/:region/:area/:poi`, async function(req, res) {
|
|
132
|
-
try {
|
|
133
|
-
const foundUser = await db.user.findById(req.session.currentUser);
|
|
134
|
-
const foundInventory = await db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
135
111
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
112
|
+
await res.render(`explorer`, context);
|
|
113
|
+
}
|
|
114
|
+
else next();
|
|
115
|
+
}
|
|
116
|
+
catch(err) {
|
|
117
|
+
console.log(err);
|
|
118
|
+
res.status(500).end();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
router.get(`/:region/:area/:poi`, async function(req, res, next) {
|
|
123
|
+
try {
|
|
124
|
+
let main = `${req.worldDir}/${req.params.region}/${req.params.area}/${req.params.poi}/views/index`;
|
|
125
|
+
|
|
126
|
+
if (fs.existsSync(main + ".ejs")) {
|
|
127
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
128
|
+
const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
129
|
+
|
|
130
|
+
let context = {
|
|
131
|
+
siteTitle: `NotherBase - ${req.params.poi}`,
|
|
132
|
+
user: foundUser,
|
|
133
|
+
main: main,
|
|
134
|
+
pov: req.query.pov,
|
|
135
|
+
inventory: foundInventory,
|
|
136
|
+
query: req.query,
|
|
137
|
+
dir: req.worldDir,
|
|
138
|
+
route: `/${req.params.region}/${req.params.area}/${req.params.poi}`
|
|
161
139
|
}
|
|
162
|
-
}
|
|
163
|
-
catch(err) {
|
|
164
|
-
console.log(err);
|
|
165
|
-
res.status(500).end();
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// start location
|
|
170
|
-
router.get("/", function(req, res) {
|
|
171
|
-
res.redirect("/the-front");
|
|
172
|
-
});
|
|
173
140
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
141
|
+
await res.render(`explorer`, context);
|
|
142
|
+
}
|
|
143
|
+
else next();
|
|
144
|
+
}
|
|
145
|
+
catch(err) {
|
|
146
|
+
console.log(err);
|
|
147
|
+
res.status(500).end();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// start location
|
|
152
|
+
router.get("/", function(req, res) {
|
|
153
|
+
res.redirect("/the-front");
|
|
154
|
+
});
|
|
188
155
|
|
|
189
|
-
|
|
156
|
+
export default router;
|
package/controllers/game.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import express from "express";
|
|
2
2
|
const router = express.Router();
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const { game } = require("../models");
|
|
4
|
+
import { game } from "../models/index.js";
|
|
6
5
|
|
|
7
6
|
router.get("/all", async function(req, res) {
|
|
8
7
|
try {
|
|
@@ -57,4 +56,4 @@ router.post("/", async function(req, res) {
|
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
export default router;
|
package/controllers/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
game: require("./game")
|
|
12
|
-
}
|
|
1
|
+
export {default as item} from "./item.js";
|
|
2
|
+
export {default as pages} from "./pages.js";
|
|
3
|
+
export {default as user} from "./user.js";
|
|
4
|
+
export {default as authCheck} from "./authCheck.js";
|
|
5
|
+
export {default as contact} from "./contact.js";
|
|
6
|
+
export {default as explorer} from "./explorer.js";
|
|
7
|
+
export {default as front} from "./the-front.js";
|
|
8
|
+
export {default as inventory} from "./inventory.js";
|
|
9
|
+
export {default as game} from "./game.js";
|
|
10
|
+
export {default as void} from "./void.js";
|
package/controllers/inventory.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import express from "express";
|
|
2
2
|
const router = express.Router();
|
|
3
3
|
|
|
4
4
|
// Import my Data
|
|
5
|
-
|
|
5
|
+
import { inventory, item, connectionSuccess } from "../models/index.js";
|
|
6
6
|
|
|
7
7
|
router.get("/", async function(req, res) {
|
|
8
8
|
if (connectionSuccess) {
|
|
@@ -34,8 +34,7 @@ router.post("/", async function(req, res) {
|
|
|
34
34
|
|
|
35
35
|
if (foundItem) {
|
|
36
36
|
let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
|
|
37
|
-
|
|
38
|
-
console.log(foundInventory.items);
|
|
37
|
+
|
|
39
38
|
let holding = false;
|
|
40
39
|
|
|
41
40
|
for (let j = 0; j < foundInventory.items.length; j++) {
|
|
@@ -114,4 +113,4 @@ router.post("/", async function(req, res) {
|
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
export default router;
|
package/controllers/item.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import express from "express";
|
|
2
2
|
const router = express.Router();
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const items = require("../models/item");
|
|
4
|
+
import items from "../models/item.js";
|
|
6
5
|
|
|
7
6
|
router.get("/all", async function(req, res) {
|
|
8
7
|
try {
|
|
@@ -68,4 +67,4 @@ router.post("/delete", async function(req, res) {
|
|
|
68
67
|
}
|
|
69
68
|
});
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
export default router;
|
package/controllers/pages.js
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import express from "express";
|
|
2
2
|
const router = express.Router();
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
files.forEach(file => {
|
|
25
|
-
file = file.slice(0, -4);
|
|
26
|
-
|
|
27
|
-
router.get(`/${file}`, async function(req, res) {
|
|
28
|
-
const foundUser = await db.user.findById(req.session.currentUser);
|
|
29
|
-
|
|
30
|
-
res.render(`${path}/${file}.ejs`, {
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
|
|
5
|
+
router.post(`/serve/:script`, async function(req, res) {
|
|
6
|
+
try {
|
|
7
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
8
|
+
|
|
9
|
+
let scriptResult = await require(`${req.pagesDir}/scripts/${req.params.script}.js`)(db, foundUser, req.body);
|
|
10
|
+
res.send(scriptResult);
|
|
11
|
+
}
|
|
12
|
+
catch(err) {
|
|
13
|
+
console.log(err);
|
|
14
|
+
res.status(500).end();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
router.get(`/:page`, async function(req, res, next) {
|
|
19
|
+
fs.access(`${req.pagesDir}/${req.params.page}.ejs`, async (err) => {
|
|
20
|
+
if (!err) {
|
|
21
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
22
|
+
|
|
23
|
+
res.render(`${req.pagesDir}/${req.params.page}.ejs`, {
|
|
31
24
|
user: foundUser,
|
|
32
25
|
query: req.query
|
|
33
26
|
});
|
|
34
|
-
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(err);
|
|
30
|
+
next();
|
|
31
|
+
}
|
|
35
32
|
});
|
|
33
|
+
});
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
}
|
|
35
|
+
export default router;
|
package/controllers/the-front.js
CHANGED
|
@@ -1,71 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
query: req.query,
|
|
31
|
-
dir: dir,
|
|
32
|
-
route: `/the-front/${req.params.detail}`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
await res.render(`explorer`, context);
|
|
36
|
-
}
|
|
37
|
-
catch(err) {
|
|
38
|
-
console.log(err);
|
|
39
|
-
res.status(500).end();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
router.get(`/`, async function(req, res) {
|
|
44
|
-
try {
|
|
45
|
-
const foundUser = await db.user.findById(req.session.currentUser);
|
|
46
|
-
const foundInventory = await db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
47
|
-
|
|
48
|
-
let main = `${dir}/views/index`;
|
|
49
|
-
|
|
50
|
-
let context = {
|
|
51
|
-
siteTitle: `NotherBase - The Front`,
|
|
52
|
-
user: foundUser,
|
|
53
|
-
main: main,
|
|
54
|
-
inventory: foundInventory,
|
|
55
|
-
query: req.query,
|
|
56
|
-
dir: dir,
|
|
57
|
-
route: `/the-front`
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await res.render(`explorer`, context);
|
|
1
|
+
import express from "express";
|
|
2
|
+
let router = express.Router();
|
|
3
|
+
|
|
4
|
+
router.post(`/serve/:script`, async function(req, res) {
|
|
5
|
+
try {
|
|
6
|
+
let scriptResult = await require(`${worldPath}/${currentRoute}/server-scripts/${req.params.script}.js`)(req.db, "/the-front", req.session.currentUser, req.body);
|
|
7
|
+
res.send(scriptResult);
|
|
8
|
+
}
|
|
9
|
+
catch(err) {
|
|
10
|
+
console.log(err);
|
|
11
|
+
res.status(500).end();
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
router.get(`/:detail`, async function(req, res) {
|
|
16
|
+
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
|
+
let main = `${req.frontDir}/views/${req.params.detail}`;
|
|
21
|
+
|
|
22
|
+
let context = {
|
|
23
|
+
siteTitle: `NotherBase - ${req.params.detail}`,
|
|
24
|
+
user: foundUser,
|
|
25
|
+
main: main,
|
|
26
|
+
inventory: foundInventory,
|
|
27
|
+
query: req.query,
|
|
28
|
+
dir: req.frontDir,
|
|
29
|
+
route: `/the-front/${req.params.detail}`
|
|
61
30
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
31
|
+
|
|
32
|
+
res.render(`explorer`, context);
|
|
33
|
+
}
|
|
34
|
+
catch(err) {
|
|
35
|
+
console.log(err);
|
|
36
|
+
res.status(500).end();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
router.get(`/`, async function(req, res) {
|
|
41
|
+
try {
|
|
42
|
+
const foundUser = await req.db.user.findById(req.session.currentUser);
|
|
43
|
+
const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
|
|
44
|
+
|
|
45
|
+
let main = `${req.frontDir}/views/index`;
|
|
46
|
+
|
|
47
|
+
let context = {
|
|
48
|
+
siteTitle: `NotherBase - The Front`,
|
|
49
|
+
user: foundUser,
|
|
50
|
+
main: main,
|
|
51
|
+
inventory: foundInventory,
|
|
52
|
+
query: req.query,
|
|
53
|
+
dir: req.frontDir,
|
|
54
|
+
route: `/the-front`
|
|
65
55
|
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return router;
|
|
69
|
-
}
|
|
70
56
|
|
|
71
|
-
|
|
57
|
+
res.render(`explorer`, context);
|
|
58
|
+
}
|
|
59
|
+
catch(err) {
|
|
60
|
+
console.log(err);
|
|
61
|
+
res.status(500).end();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default router;
|