notherbase-fs 4.0.22 → 4.1.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 (55) hide show
  1. package/README.md +6 -6
  2. package/controllers/creation.js +171 -147
  3. package/controllers/spirit-world.js +174 -174
  4. package/controllers/user.js +240 -240
  5. package/controllers/util.js +64 -64
  6. package/models/index.js +33 -33
  7. package/models/send-mail.js +58 -58
  8. package/models/spirit.js +234 -234
  9. package/notherbase-fs.js +114 -112
  10. package/package.json +40 -40
  11. package/public/js/base.js +222 -227
  12. package/public/js/chat-box.js +120 -120
  13. package/test/coast/tall-beach/nono-cove/index.css +17 -17
  14. package/test/coast/tall-beach/nono-cove/index.ejs +29 -29
  15. package/test/coast/tall-beach/nono-cove/nono-og/add-gold.js +15 -15
  16. package/test/coast/tall-beach/nono-cove/nono-og/index.ejs +46 -46
  17. package/test/coast/tall-beach/nono-cove/nono-og/nono.css +88 -88
  18. package/test/coast/tall-beach/nono-cove/nono-og/nono.js +207 -207
  19. package/test/pages/test-page/emailTime.js +8 -8
  20. package/test/pages/test-page/index.ejs +104 -104
  21. package/test/pages/void/index.ejs +35 -35
  22. package/test/pages/void/void.css +2 -2
  23. package/test/public/styles/main.css +792 -792
  24. package/test/the-front/add-gold.js +13 -13
  25. package/test/the-front/check/_preprocess/saved.js +9 -0
  26. package/test/the-front/check/check.css +2 -2
  27. package/test/the-front/check/emailTime.js +9 -9
  28. package/test/the-front/check/flip.js +9 -9
  29. package/test/the-front/check/index.ejs +55 -54
  30. package/test/the-front/check/save-input.js +7 -7
  31. package/test/the-front/index.ejs +116 -99
  32. package/test/the-front/keeper/clipboards.js +133 -133
  33. package/test/the-front/keeper/index.ejs +80 -80
  34. package/test/the-front/keeper/keeper.css +157 -157
  35. package/test/the-front/keeper/keeper.js +140 -140
  36. package/test-index.js +19 -19
  37. package/test2/pages/test-page/emailTime.js +8 -8
  38. package/test2/pages/test-page/index.ejs +104 -104
  39. package/test2/pages/void/index.ejs +35 -35
  40. package/test2/pages/void/void.css +2 -2
  41. package/test2/public/styles/main.css +792 -792
  42. package/test2/the-front/add-gold.js +13 -13
  43. package/test2/the-front/check/check.css +2 -2
  44. package/test2/the-front/check/emailTime.js +9 -9
  45. package/test2/the-front/check/flip.js +9 -9
  46. package/test2/the-front/check/index.ejs +54 -54
  47. package/test2/the-front/check/save-input.js +7 -7
  48. package/test2/the-front/index.ejs +99 -99
  49. package/test2/the-front/keeper/clipboards.js +133 -133
  50. package/test2/the-front/keeper/index.ejs +80 -80
  51. package/test2/the-front/keeper/keeper.css +157 -157
  52. package/test2/the-front/keeper/keeper.js +140 -140
  53. package/views/explorer.ejs +82 -82
  54. package/views/footer.ejs +9 -9
  55. package/views/head.ejs +17 -17
package/notherbase-fs.js CHANGED
@@ -1,113 +1,115 @@
1
- import dotenv from "dotenv";
2
- dotenv.config();
3
- import Models from "./models/index.js";
4
- import { Server } from "socket.io";
5
- import express from "express";
6
- import http from 'http';
7
- import { fileURLToPath } from 'node:url';
8
- const __dirname = fileURLToPath(new URL('./', import.meta.url));
9
- import Creation from "./controllers/creation.js";
10
- import SpiritWorld from "./controllers/spirit-world.js";
11
- import favicon from 'serve-favicon';
12
- import session from 'express-session';
13
- import MongoStore from 'connect-mongo';
14
-
15
-
16
- /**
17
- * The engine that runs a nother base.
18
- */
19
- class NotherBaseFS {
20
- constructor(globals = {}, bases = {}) {
21
- this.bases = bases;
22
-
23
- this.app = express();
24
- this.server = http.createServer(this.app);
25
- this.io = new Server(this.server);
26
- this.spiritWorld = new SpiritWorld(this.io);
27
- this.creation = new Creation(bases);
28
-
29
- //set views path
30
- this.app.set("view engine", "ejs");
31
- this.app.set("views", `${__dirname}/views`);
32
-
33
- // allows us to use post body data
34
- this.app.use(express.json({
35
- extended: true,
36
- inflate: true,
37
- type: 'application/x-www-form-urlencoded'
38
- }));
39
-
40
- //be safe, needs to be before session
41
- if (process.env.PRODUCTION == "true") this.app.set('trust proxy', 1);
42
-
43
- let baseKeys = Object.keys(this.bases);
44
- let store = MongoStore.create({ mongoUrl: process.env.MONGODB_URI });
45
- for (let i = 0; i < baseKeys.length; i++) {
46
- this.bases[baseKeys[i]].static = express.static(this.bases[baseKeys[i]].directory + "/public");
47
- this.bases[baseKeys[i]].favicon = favicon(this.bases[baseKeys[i]].directory + this.bases[baseKeys[i]].icon);
48
- this.bases[baseKeys[i]].session = session({
49
- store: store,
50
- secret: process.env.SECRET,
51
- name: baseKeys[i] + '-session-id',
52
- resave: false,
53
- saveUninitialized: false,
54
- cookie: {
55
- secure: process.env.PRODUCTION == "true",
56
- maxAge: 1000 * 60 * 60 * 24 * 28 // 28 days
57
- }
58
- });
59
- }
60
-
61
- //provide database access and etc to use in routes
62
- this.app.use((req, res, next) => {
63
- let split = req.hostname.split(".");
64
- if (split.length > 2) {
65
- if (split[split.length - 2].length < 3) req.hosting = split[split.length - 3] + split[split.length - 2];
66
- else req.hosting = split[split.length - 2];
67
- }
68
- else req.hosting = split[0];
69
-
70
- req.contentPath = this.bases[req.hosting].directory;
71
- next();
72
- });
73
-
74
- this.app.use((req, res, next) => {
75
- this.bases[req.hosting].favicon(req, res, next);
76
- });
77
-
78
- //enable cookies
79
- this.app.use((req, res, next) => {
80
- this.bases[req.hosting].session(req, res, next);
81
- });
82
-
83
- // allows us to get static files like css
84
- this.app.use(express.static(`${__dirname}/public`));
85
- this.app.use((req, res, next) => {
86
- this.bases[req.hosting].static(req, res, next);
87
- });
88
-
89
- //provide database access and etc to use in routes
90
- this.app.use((req, res, next) => {
91
- req.globals = globals;
92
- req.db = Models;
93
- req.lock = false;
94
- // enables sessions only if the protocol is https and we are in production, or if we are in development
95
- req.sessionsEnabled = (process.env.PRODUCTION == "true" && req.secure) || process.env.PRODUCTION == "false";
96
- next();
97
- });
98
-
99
- //spirit world routes
100
- this.app.use("/s", this.spiritWorld.router);
101
-
102
- //all actual pages
103
- this.app.use("/", this.creation.router);
104
-
105
- //start the server
106
- this.server.listen(process.env.PORT, function () {
107
- console.log(`Server started at ${process.env.PORT}`);
108
- this.started = true;
109
- });
110
- }
111
- }
112
-
1
+ import dotenv from "dotenv";
2
+ dotenv.config();
3
+ import Models from "./models/index.js";
4
+ import { Server } from "socket.io";
5
+ import express from "express";
6
+ import http from 'http';
7
+ import { fileURLToPath } from 'node:url';
8
+ const __dirname = fileURLToPath(new URL('./', import.meta.url));
9
+ import Creation from "./controllers/creation.js";
10
+ import SpiritWorld from "./controllers/spirit-world.js";
11
+ import favicon from 'serve-favicon';
12
+ import session from 'express-session';
13
+ import MongoStore from 'connect-mongo';
14
+
15
+
16
+ /**
17
+ * The engine that runs a nother base.
18
+ */
19
+ class NotherBaseFS {
20
+ constructor(globals = {}, bases = {}) {
21
+ this.bases = bases;
22
+
23
+ this.app = express();
24
+ this.server = http.createServer(this.app);
25
+ this.io = new Server(this.server);
26
+ this.spiritWorld = new SpiritWorld(this.io);
27
+ this.creation = new Creation(bases);
28
+
29
+ //set view engine
30
+ this.app.set("view engine", "ejs");
31
+
32
+ //set views path
33
+ this.app.set("views", `${__dirname}/views`);
34
+
35
+ // allows us to use post body data
36
+ this.app.use(express.json({
37
+ extended: true,
38
+ inflate: true,
39
+ type: 'application/x-www-form-urlencoded'
40
+ }));
41
+
42
+ //be safe, needs to be before session
43
+ if (process.env.PRODUCTION == "true") this.app.set('trust proxy', 1);
44
+
45
+ let baseKeys = Object.keys(this.bases);
46
+ let store = MongoStore.create({ mongoUrl: process.env.MONGODB_URI });
47
+ for (let i = 0; i < baseKeys.length; i++) {
48
+ this.bases[baseKeys[i]].static = express.static(this.bases[baseKeys[i]].directory + "/public");
49
+ this.bases[baseKeys[i]].favicon = favicon(this.bases[baseKeys[i]].directory + this.bases[baseKeys[i]].icon);
50
+ this.bases[baseKeys[i]].session = session({
51
+ store: store,
52
+ secret: process.env.SECRET,
53
+ name: baseKeys[i] + '-session-id',
54
+ resave: false,
55
+ saveUninitialized: false,
56
+ cookie: {
57
+ secure: process.env.PRODUCTION == "true",
58
+ maxAge: 1000 * 60 * 60 * 24 * 28 // 28 days
59
+ }
60
+ });
61
+ }
62
+
63
+ //provide database access and etc to use in routes
64
+ this.app.use((req, res, next) => {
65
+ let split = req.hostname.split(".");
66
+ if (split.length > 2) {
67
+ if (split[split.length - 2].length < 3) req.hosting = split[split.length - 3] + split[split.length - 2];
68
+ else req.hosting = split[split.length - 2];
69
+ }
70
+ else req.hosting = split[0];
71
+
72
+ req.contentPath = this.bases[req.hosting].directory;
73
+ next();
74
+ });
75
+
76
+ this.app.use((req, res, next) => {
77
+ this.bases[req.hosting].favicon(req, res, next);
78
+ });
79
+
80
+ //enable cookies
81
+ this.app.use((req, res, next) => {
82
+ this.bases[req.hosting].session(req, res, next);
83
+ });
84
+
85
+ // allows us to get static files like css
86
+ this.app.use((req, res, next) => {
87
+ this.bases[req.hosting].static(req, res, next);
88
+ });
89
+ this.app.use(express.static(`${__dirname}/public`));
90
+
91
+ //provide database access and etc to use in routes
92
+ this.app.use((req, res, next) => {
93
+ req.globals = globals;
94
+ req.db = Models;
95
+ req.lock = false;
96
+ // enables sessions only if the protocol is https and we are in production, or if we are in development
97
+ req.sessionsEnabled = (process.env.PRODUCTION == "true" && req.secure) || process.env.PRODUCTION == "false";
98
+ next();
99
+ });
100
+
101
+ //spirit world routes
102
+ this.app.use("/s", this.spiritWorld.router);
103
+
104
+ //all actual pages
105
+ this.app.use("/", this.creation.router);
106
+
107
+ //start the server
108
+ this.server.listen(process.env.PORT, function () {
109
+ console.log(`Server started at ${process.env.PORT}`);
110
+ this.started = true;
111
+ });
112
+ }
113
+ }
114
+
113
115
  export default NotherBaseFS;
package/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "notherbase-fs",
3
- "version": "4.0.22",
4
- "description": "Functions to help make developing for NotherBase easier.",
5
- "exports": "./notherbase-fs.js",
6
- "scripts": {
7
- "test": "nodemon test-index.js",
8
- "gmail-auth": "node gmail-auth.js",
9
- "gmail-token": "node gmail-token.js"
10
- },
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/Mosshide/notherbase-fs.git"
14
- },
15
- "author": "Wyatt Sushinsky",
16
- "license": "ISC",
17
- "bugs": {
18
- "url": "https://github.com/Mosshide/notherbase-fs/issues"
19
- },
20
- "homepage": "https://github.com/Mosshide/notherbase-fs#readme",
21
- "dependencies": {
22
- "bcrypt": "^5.0.1",
23
- "connect-mongo": "^4.6.0",
24
- "dotenv": "^14.2.0",
25
- "ejs": "^3.1.6",
26
- "express": "^4.17.1",
27
- "express-session": "^1.17.2",
28
- "express-subdomain": "^1.0.6",
29
- "googleapis": "^100.0.0",
30
- "mongoose": "^6.1.7",
31
- "nodemailer": "^6.9.14",
32
- "serve-favicon": "^2.5.0",
33
- "socket.io": "^4.4.1",
34
- "string-strip-html": "^13.0.0"
35
- },
36
- "type": "module",
37
- "engines": {
38
- "node": ">=14.16"
39
- }
40
- }
1
+ {
2
+ "name": "notherbase-fs",
3
+ "version": "4.1.0",
4
+ "description": "Functions to help make developing for NotherBase easier.",
5
+ "exports": "./notherbase-fs.js",
6
+ "scripts": {
7
+ "test": "nodemon test-index.js",
8
+ "gmail-auth": "node gmail-auth.js",
9
+ "gmail-token": "node gmail-token.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/Mosshide/notherbase-fs.git"
14
+ },
15
+ "author": "Wyatt Sushinsky",
16
+ "license": "ISC",
17
+ "bugs": {
18
+ "url": "https://github.com/Mosshide/notherbase-fs/issues"
19
+ },
20
+ "homepage": "https://github.com/Mosshide/notherbase-fs#readme",
21
+ "dependencies": {
22
+ "bcrypt": "^5.0.1",
23
+ "connect-mongo": "^4.6.0",
24
+ "dotenv": "^14.2.0",
25
+ "ejs": "^3.1.6",
26
+ "express": "^4.17.1",
27
+ "express-session": "^1.17.2",
28
+ "express-subdomain": "^1.0.6",
29
+ "googleapis": "^100.0.0",
30
+ "mongoose": "^6.1.7",
31
+ "nodemailer": "^6.9.14",
32
+ "serve-favicon": "^2.5.0",
33
+ "socket.io": "^4.4.1",
34
+ "string-strip-html": "^13.0.0"
35
+ },
36
+ "type": "module",
37
+ "engines": {
38
+ "node": ">=14.16"
39
+ }
40
+ }