notherbase-fs 1.5.2 → 2.0.0

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.
Files changed (52) hide show
  1. package/controllers/creation.js +90 -0
  2. package/controllers/spirit-world.js +110 -0
  3. package/controllers/spirits/attribute.js +47 -0
  4. package/controllers/spirits/contact.js +16 -0
  5. package/controllers/spirits/inventory.js +71 -0
  6. package/controllers/spirits/item.js +41 -0
  7. package/controllers/spirits/serve.js +33 -0
  8. package/controllers/spirits/user.js +130 -0
  9. package/controllers/spirits/util.js +39 -0
  10. package/models/index.js +130 -14
  11. package/models/spirit.js +159 -0
  12. package/notherbase-fs.js +23 -73
  13. package/package.json +2 -2
  14. package/public/js/commune.js +22 -0
  15. package/public/js/establishment.js +44 -0
  16. package/public/js/memories.js +29 -30
  17. package/public/styles/main.css +9 -99
  18. package/test/explorer/coast/tall-beach/nono-cove/server-scripts/emailTime.js +7 -3
  19. package/test/explorer/coast/tall-beach/nono-cove/views/index.ejs +38 -60
  20. package/test/pages/server-scripts/emailTime.js +15 -0
  21. package/test/pages/test.ejs +30 -3
  22. package/test/the-front/server-scripts/emailTime.js +7 -3
  23. package/test/the-front/server-scripts/migrateBig.js +3 -0
  24. package/test/the-front/views/check.ejs +88 -2
  25. package/test/the-front/views/index.ejs +43 -101
  26. package/test-index.js +5 -0
  27. package/views/account.ejs +25 -36
  28. package/views/explorer.ejs +48 -1
  29. package/views/inventory.ejs +41 -99
  30. package/views/menu.ejs +8 -2
  31. package/views/more.ejs +8 -14
  32. package/views/player.ejs +37 -24
  33. package/controllers/authCheck.js +0 -18
  34. package/controllers/contact.js +0 -22
  35. package/controllers/explorer.js +0 -150
  36. package/controllers/game.js +0 -59
  37. package/controllers/index.js +0 -10
  38. package/controllers/inventory.js +0 -116
  39. package/controllers/item.js +0 -70
  40. package/controllers/pages.js +0 -34
  41. package/controllers/the-front.js +0 -70
  42. package/controllers/user.js +0 -413
  43. package/controllers/void.js +0 -16
  44. package/models/chat.js +0 -9
  45. package/models/contact.js +0 -14
  46. package/models/detail.js +0 -16
  47. package/models/game.js +0 -8
  48. package/models/inventory.js +0 -19
  49. package/models/item.js +0 -12
  50. package/models/page.js +0 -14
  51. package/models/user.js +0 -25
  52. package/test/test-index.js +0 -5
@@ -1,59 +0,0 @@
1
- import express from "express";
2
- const router = express.Router();
3
-
4
- import { game } from "../models/index.js";
5
-
6
- router.get("/all", async function(req, res) {
7
- try {
8
- let foundGames = await game.find({name: req.query.name});
9
-
10
- res.status(200).send({ foundGames: foundGames });
11
- }
12
- catch(err) {
13
- res.status(500).end();
14
- console.log(err);
15
- }
16
- });
17
-
18
- router.get("/one", async function(req, res) {
19
- try {
20
- let foundGame = await game.findOne({_id: req.query._id});
21
-
22
- if (!foundGame) res.status(404).end();
23
- else res.status(200).send({ foundGame: foundGame });
24
- }
25
- catch(err) {
26
- res.status(500).end();
27
- console.log(err);
28
- }
29
- });
30
-
31
- router.post("/", async function(req, res) {
32
- try {
33
- let foundGame = await game.findOne({_id: req.query._id});
34
-
35
- if (!foundGame) {
36
- await game.create({
37
- name: req.body.name,
38
- shortDescription: req.body.shortDescription,
39
- fullDescription: req.body.fullDescription
40
- });
41
-
42
- res.status(200).end();
43
- }
44
- else {
45
- foundGame.data = req.query.data;
46
- foundGame.markModified("data");
47
- await foundGame.save();
48
-
49
- res.status(200).end();
50
- }
51
- }
52
- catch(err) {
53
- res.status(500).end();
54
- console.log(req.query);
55
- console.log(err);
56
- }
57
- });
58
-
59
- export default router;
@@ -1,10 +0,0 @@
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";
@@ -1,116 +0,0 @@
1
- import express from "express";
2
- const router = express.Router();
3
-
4
- // Import my Data
5
- import { inventory, item, connectionSuccess } from "../models/index.js";
6
-
7
- router.get("/", async function(req, res) {
8
- if (connectionSuccess) {
9
- try {
10
- if (req.session.currentUser) {
11
- let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
12
-
13
- res.status(200).send({ foundInventory: foundInventory });
14
- }
15
- else {
16
- res.status(401).end();
17
- }
18
- }
19
- catch(err) {
20
- console.log(err);
21
- res.status(500).end();
22
- }
23
- }
24
- else {
25
- res.status(500).end();
26
- }
27
- });
28
-
29
- router.post("/", async function(req, res) {
30
- if (connectionSuccess) {
31
- try {
32
- if (req.body.item && req.body.amount) {
33
- let foundItem = await item.findOne({name: req.body.item});
34
-
35
- if (foundItem) {
36
- let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
37
-
38
- let holding = false;
39
-
40
- for (let j = 0; j < foundInventory.items.length; j++) {
41
- if (foundInventory.items[j].item.name === req.body.item) {
42
- holding = true;
43
-
44
- if (foundInventory.items[j].amount >= -Math.floor(req.body.amount)) {
45
- foundInventory.items[j].amount += Math.floor(req.body.amount);
46
-
47
- if (foundInventory.items[j].amount === 0) {
48
- let itemToEmpty = foundInventory.items[j].item._id;
49
-
50
- foundInventory.items.splice(j, 1);
51
- await foundInventory.save();
52
-
53
- res.status(200).send({
54
- item: {
55
- _id: itemToEmpty
56
- },
57
- amount: 0
58
- });
59
- }
60
- else {
61
- await foundInventory.save();
62
- res.status(200).send(foundInventory.items[j]);
63
- }
64
- }
65
- else {
66
- res.status(304).send(
67
- `Unable to remove ${req.body.amount} ${req.body.item}
68
- from inventory because the inventory has only ${foundInventory.items[j].amount}.`
69
- );
70
- }
71
-
72
- break;
73
- }
74
- }
75
-
76
- if (!holding) {
77
- if (req.body.amount > 0) {
78
- foundInventory.items.push({
79
- item: foundItem._id,
80
- amount: req.body.amount
81
- });
82
-
83
- await foundInventory.save();
84
-
85
- await inventory.populate(foundInventory, "items.item");
86
-
87
- res.status(200).send(foundInventory.items[foundInventory.items.length - 1]);
88
- }
89
- else {
90
- res.status(304).send(
91
- `Unable to remove ${req.body.amount} ${req.body.item}
92
- from inventory because the inventory has none.`
93
- );
94
- }
95
- };
96
- }
97
- else {
98
- res.status(400).send(`${req.body.item} doesn't exist!`);
99
- }
100
- }
101
- else {
102
- res.status(400).send(`${req.body.item} ${req.body.amount} Check Input!`);
103
- }
104
- }
105
- catch(err) {
106
- res.status(500).end();
107
- console.log(err);
108
- }
109
- }
110
- else {
111
- res.status(500).end();
112
- }
113
- });
114
-
115
-
116
- export default router;
@@ -1,70 +0,0 @@
1
- import express from "express";
2
- const router = express.Router();
3
-
4
- import items from "../models/item.js";
5
-
6
- router.get("/all", async function(req, res) {
7
- try {
8
- let foundItems = await items.find({});
9
-
10
- res.status(200).send({ foundItems: foundItems });
11
- }
12
- catch(err) {
13
- res.status(500).end();
14
- console.log(err);
15
- }
16
- });
17
-
18
- router.get("/", async function(req, res) {
19
- try {
20
- let foundItem = await items.findOne({ name: req.query.name });
21
-
22
- res.status(200).send({ foundItem: foundItem });
23
- }
24
- catch(err) {
25
- res.status(500).end();
26
- console.log(err);
27
- }
28
- });
29
-
30
- router.post("/", async function(req, res) {
31
- try {
32
- if (!req.body.id) {
33
- await items.create({
34
- name: req.body.name,
35
- shortDescription: req.body.shortDescription,
36
- fullDescription: req.body.fullDescription
37
- });
38
- }
39
- else {
40
- let foundItem = await items.findById(req.body.id);
41
-
42
- if (foundItem) {
43
- foundItem.name = req.body.name;
44
- foundItem.shortDescription = req.body.shortDescription;
45
- foundItem.fullDescription = req.body.fullDescription;
46
- await foundItem.save();
47
- }
48
- }
49
-
50
- res.status(200).end();
51
- }
52
- catch(err) {
53
- res.status(500).end();
54
- console.log(err);
55
- }
56
- });
57
-
58
- router.post("/delete", async function(req, res) {
59
- try {
60
- await items.findByIdAndDelete(req.body.id);
61
-
62
- res.status(200).end();
63
- }
64
- catch(err) {
65
- res.status(500).end();
66
- console.log(err);
67
- }
68
- });
69
-
70
- export default router;
@@ -1,34 +0,0 @@
1
- import express from "express";
2
- const router = express.Router();
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 script = await import(`${req.pagesDir}/scripts/${req.params.script}.js`);
10
- let scriptResult = await script.default(req.db, foundUser, req.body);
11
- res.send(scriptResult);
12
- }
13
- catch(err) {
14
- console.log(err);
15
- res.status(500).end();
16
- }
17
- });
18
-
19
- router.get(`/:page`, async function(req, res, next) {
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
- }
32
- });
33
-
34
- export default router;
@@ -1,70 +0,0 @@
1
- import express from "express";
2
- let router = express.Router();
3
- import fs from 'fs';
4
-
5
- router.post(`/serve/:script`, async function(req, res) {
6
- try {
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);
9
- res.send(scriptResult);
10
- }
11
- catch(err) {
12
- console.log(err);
13
- res.status(500).end();
14
- }
15
- });
16
-
17
- router.get(`/:detail`, async function(req, res, next) {
18
- try {
19
- let main = `${req.frontDir}/views/${req.params.detail}`;
20
-
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);
37
- }
38
- else next();
39
- }
40
- catch(err) {
41
- console.log(err);
42
- res.status(500).end();
43
- }
44
- });
45
-
46
- router.get(`/`, async function(req, res) {
47
- try {
48
- let main = `${req.frontDir}/views/index`;
49
- const foundUser = await req.db.user.findById(req.session.currentUser);
50
- const foundInventory = await req.db.inventory.findOne({ user: req.session.currentUser }).populate("items.item");
51
-
52
- let context = {
53
- siteTitle: `NotherBase - The Front`,
54
- user: foundUser,
55
- main: main,
56
- inventory: foundInventory,
57
- query: req.query,
58
- dir: req.frontDir,
59
- route: `/the-front`
60
- }
61
-
62
- res.render(`explorer`, context);
63
- }
64
- catch(err) {
65
- console.log(err);
66
- res.status(500).end();
67
- }
68
- });
69
-
70
- export default router;