notherbase-fs 2.0.2 → 3.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.
- package/controllers/creation.js +57 -59
- package/controllers/spirit-world.js +55 -72
- package/controllers/spirits/contact.js +17 -10
- package/controllers/spirits/user.js +144 -112
- package/controllers/spirits/util.js +23 -31
- package/models/index.js +54 -117
- package/models/item.js +80 -0
- package/models/send-mail.js +2 -0
- package/models/spirit.js +77 -115
- package/models/user.js +189 -0
- package/notherbase-fs.js +1 -0
- package/package.json +1 -1
- package/public/styles/main.css +12 -3
- package/test/{explorer/coast/tall-beach/nono-cove/styles → coast/tall-beach/nono-cove}/index.css +0 -0
- package/test/coast/tall-beach/nono-cove/index.ejs +29 -0
- package/test/{explorer/coast/tall-beach/nono-cove/views/nono-og.ejs → coast/tall-beach/nono-cove/nono-og/index.ejs} +2 -2
- package/test/{explorer/coast/tall-beach/nono-cove/styles → coast/tall-beach/nono-cove/nono-og}/nono.css +0 -0
- package/test/{explorer/coast/tall-beach/nono-cove/local-scripts → coast/tall-beach/nono-cove/nono-og}/nono.js +1 -1
- package/test/{explorer/coast/tall-beach/nono-cove/server-scripts → test-page}/emailTime.js +0 -0
- package/test/{pages/test.ejs → test-page/index.ejs} +0 -0
- package/test/the-front/add-gold.js +35 -0
- package/test/the-front/check/add-more-gold.js +3 -0
- package/test/the-front/check/emailTime.js +11 -0
- package/test/the-front/check/index.ejs +13 -0
- package/test/the-front/check/subtract-gold.js +3 -0
- package/test/the-front/checks.js +11 -0
- package/test/the-front/incTranslation.js +9 -0
- package/test/the-front/index.ejs +107 -0
- package/test/void/index.ejs +4 -0
- package/test/void/void.css +3 -0
- package/views/explorer.ejs +32 -41
- package/views/menu/account.ejs +39 -0
- package/views/menu/inventory.ejs +8 -0
- package/views/menu/more.ejs +5 -0
- package/views/menu/player.ejs +3 -0
- package/views/menu.ejs +20 -62
- package/views/scripts/base.js +314 -0
- package/controllers/spirits/attribute.js +0 -47
- package/controllers/spirits/inventory.js +0 -71
- package/controllers/spirits/item.js +0 -41
- package/controllers/spirits/serve.js +0 -33
- package/public/js/commune.js +0 -22
- package/public/js/establishment.js +0 -44
- package/public/js/memories.js +0 -44
- package/test/explorer/coast/tall-beach/nono-cove/local-scripts/game.js +0 -7
- package/test/explorer/coast/tall-beach/nono-cove/local-scripts/items.js +0 -162
- package/test/explorer/coast/tall-beach/nono-cove/server-scripts/getTimer.js +0 -31
- package/test/explorer/coast/tall-beach/nono-cove/styles/items-floor.css +0 -92
- package/test/explorer/coast/tall-beach/nono-cove/views/index.ejs +0 -130
- package/test/pages/server-scripts/emailTime.js +0 -15
- package/test/the-front/server-scripts/emailTime.js +0 -15
- package/test/the-front/server-scripts/getTimer.js +0 -31
- package/test/the-front/views/check.ejs +0 -93
- package/test/the-front/views/index.ejs +0 -113
- package/test/void/styles/void.css +0 -0
- package/views/account.ejs +0 -122
- package/views/inventory.ejs +0 -117
- package/views/more.ejs +0 -16
- package/views/player.ejs +0 -60
package/models/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import mongoose from "mongoose";
|
|
|
2
2
|
import dotenv from "dotenv";
|
|
3
3
|
dotenv.config();
|
|
4
4
|
import Spirit from "./spirit.js";
|
|
5
|
+
import Item from "./item.js";
|
|
6
|
+
import User from "./user.js";
|
|
5
7
|
import SendMail from "./send-mail.js";
|
|
6
8
|
|
|
7
9
|
mongoose.connection.on('connected', (err) => {
|
|
@@ -26,128 +28,63 @@ catch (err) {
|
|
|
26
28
|
console.log(`Mongoose on connect: ${err}`);
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
commit = async (data = this.memory.data) => {
|
|
62
|
-
let result = await this.commitByData("name", this.memory.data.name, data);
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
delete = async () => {
|
|
67
|
-
let result = await this.deleteByData("name", this.memory.data.name);
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// migrate
|
|
74
|
-
// const user = mongoose.model('users', new mongoose.Schema({
|
|
75
|
-
// username: String,
|
|
76
|
-
// password: String,
|
|
77
|
-
// email: String,
|
|
78
|
-
// coin: Number,
|
|
79
|
-
// home: String,
|
|
80
|
-
// authLevels: [ String ],
|
|
81
|
-
// location: String,
|
|
82
|
-
// attributes: {
|
|
83
|
-
// translation: Number,
|
|
84
|
-
// strength: Number,
|
|
85
|
-
// agility: Number,
|
|
86
|
-
// defense: Number
|
|
87
|
-
// },
|
|
88
|
-
// reset: {
|
|
89
|
-
// token: Number,
|
|
90
|
-
// exp: Number
|
|
91
|
-
// }
|
|
92
|
-
// }));
|
|
93
|
-
// const page = mongoose.model('pages', new mongoose.Schema({
|
|
94
|
-
// name: String,
|
|
95
|
-
// type: String,
|
|
96
|
-
// user: {
|
|
97
|
-
// type: mongoose.Schema.Types.ObjectId,
|
|
98
|
-
// ref: "users",
|
|
99
|
-
// required: false
|
|
100
|
-
// },
|
|
101
|
-
// data: {}
|
|
102
|
-
// }));
|
|
103
|
-
|
|
104
|
-
// user.find({}, async (err, users) => {
|
|
105
|
-
// for (let i = 0; i < users.length; i++) {
|
|
106
|
-
// let userSpirit = new User("user", users[i].email);
|
|
107
|
-
|
|
108
|
-
// await userSpirit.create({
|
|
109
|
-
// username: users[i].username,
|
|
110
|
-
// password: users[i].password,
|
|
111
|
-
// email: users[i].email,
|
|
112
|
-
// coin: users[i].coin,
|
|
113
|
-
// home: users[i].home,
|
|
114
|
-
// authLevels: users[i].authLevels,
|
|
115
|
-
// location: users[i].location,
|
|
116
|
-
// attributes: users[i].attributes,
|
|
117
|
-
// inventory: []
|
|
118
|
-
// });
|
|
119
|
-
|
|
120
|
-
// let foundPages = await page.find({ user: users[i]._id });
|
|
121
|
-
|
|
122
|
-
// for (let i = 0; i < foundPages.length; i++) {
|
|
123
|
-
// let spirit = new Spirit({
|
|
124
|
-
// route: `/${foundPages[i].name}`,
|
|
125
|
-
// service: foundPages[i].name,
|
|
126
|
-
// scope: foundPages[i].type,
|
|
127
|
-
// parent: userSpirit.memory._id,
|
|
128
|
-
// _lastUpdate: 0,
|
|
129
|
-
// data: foundPages[i].data.tickets
|
|
130
|
-
// });
|
|
31
|
+
// let migrate = function () {
|
|
32
|
+
// // migrate
|
|
33
|
+
|
|
34
|
+
// const user = mongoose.model('users', new mongoose.Schema({
|
|
35
|
+
// username: String,
|
|
36
|
+
// password: String,
|
|
37
|
+
// email: String,
|
|
38
|
+
// coin: Number,
|
|
39
|
+
// home: String,
|
|
40
|
+
// authLevels: [ String ],
|
|
41
|
+
// location: String,
|
|
42
|
+
// attributes: {
|
|
43
|
+
// translation: Number,
|
|
44
|
+
// strength: Number,
|
|
45
|
+
// agility: Number,
|
|
46
|
+
// defense: Number
|
|
47
|
+
// },
|
|
48
|
+
// reset: {
|
|
49
|
+
// token: Number,
|
|
50
|
+
// exp: Number
|
|
51
|
+
// }
|
|
52
|
+
// }));
|
|
53
|
+
// const page = mongoose.model('pages', new mongoose.Schema({
|
|
54
|
+
// name: String,
|
|
55
|
+
// type: String,
|
|
56
|
+
// user: {
|
|
57
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
58
|
+
// ref: "users",
|
|
59
|
+
// required: false
|
|
60
|
+
// },
|
|
61
|
+
// data: {}
|
|
62
|
+
// }));
|
|
131
63
|
|
|
132
|
-
//
|
|
64
|
+
// user.find({}, async (err, users) => {
|
|
65
|
+
// for (let i = 0; i < users.length; i++) {
|
|
66
|
+
// let userSpirit = await User.create(
|
|
67
|
+
// users[i].username,
|
|
68
|
+
// users[i].password,
|
|
69
|
+
// users[i].email
|
|
70
|
+
// );
|
|
71
|
+
|
|
72
|
+
// let foundPages = await page.find({ user: users[i]._id });
|
|
133
73
|
|
|
134
|
-
//
|
|
135
|
-
// spirit.
|
|
136
|
-
//
|
|
74
|
+
// for (let i = 0; i < foundPages.length; i++) {
|
|
75
|
+
// let spirit = await Spirit.create({
|
|
76
|
+
// route: `/${foundPages[i].name}`,
|
|
77
|
+
// service: foundPages[i].name,
|
|
78
|
+
// scope: foundPages[i].type,
|
|
79
|
+
// parent: userSpirit.memory._id,
|
|
80
|
+
// _lastUpdate: 0
|
|
81
|
+
// }, foundPages[i].data.tickets);
|
|
137
82
|
// }
|
|
138
|
-
// else await spirit.create({
|
|
139
|
-
// tickets: foundPages[i].data.tickets
|
|
140
|
-
// });
|
|
141
83
|
// }
|
|
142
|
-
// }
|
|
143
|
-
// }
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
84
|
+
// });
|
|
85
|
+
// }
|
|
150
86
|
|
|
87
|
+
// migrate();
|
|
151
88
|
|
|
152
89
|
export default {
|
|
153
90
|
SendMail: SendMail,
|
package/models/item.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import Spirit from "./spirit.js";
|
|
2
|
+
|
|
3
|
+
export default class Item extends Spirit {
|
|
4
|
+
static create = async (name, short, long) => {
|
|
5
|
+
let spirit = new Item(name);
|
|
6
|
+
|
|
7
|
+
spirit.memory = await Spirit.db.create({
|
|
8
|
+
route: "/",
|
|
9
|
+
service: "items",
|
|
10
|
+
parent: null,
|
|
11
|
+
scope: "global",
|
|
12
|
+
_lastUpdate: Date.now(),
|
|
13
|
+
data: {
|
|
14
|
+
name,
|
|
15
|
+
short,
|
|
16
|
+
long
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return spirit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static recallAll = async () => {
|
|
24
|
+
let spirit = new Item();
|
|
25
|
+
|
|
26
|
+
let found = await Spirit.db.find({
|
|
27
|
+
route: "/",
|
|
28
|
+
service: "items",
|
|
29
|
+
parent: null,
|
|
30
|
+
scope: "global"
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (found) {
|
|
34
|
+
spirit.memory = found;
|
|
35
|
+
|
|
36
|
+
return spirit;
|
|
37
|
+
}
|
|
38
|
+
else return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static recallOne = async (name) => {
|
|
42
|
+
let spirit = new Item(name);
|
|
43
|
+
|
|
44
|
+
let query = Spirit.buildQuery({
|
|
45
|
+
route: "/",
|
|
46
|
+
service: "items",
|
|
47
|
+
parent: null,
|
|
48
|
+
scope: "global"
|
|
49
|
+
}, {
|
|
50
|
+
name: name
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
let found = await Spirit.db.findOne(query);
|
|
54
|
+
|
|
55
|
+
if (found) {
|
|
56
|
+
spirit.memory = found;
|
|
57
|
+
|
|
58
|
+
return spirit;
|
|
59
|
+
}
|
|
60
|
+
else return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static delete = async (name) => {
|
|
64
|
+
let found = await Spirit.db.findAndDelete(Spirit.buildQuery({
|
|
65
|
+
route: "/",
|
|
66
|
+
service: "items",
|
|
67
|
+
parent: null,
|
|
68
|
+
scope: "global"
|
|
69
|
+
}, {
|
|
70
|
+
name: name
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
return found.deletedCount;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
constructor(name = "") {
|
|
77
|
+
super();
|
|
78
|
+
this.name = name;
|
|
79
|
+
}
|
|
80
|
+
}
|
package/models/send-mail.js
CHANGED
package/models/spirit.js
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
|
|
3
3
|
export default class Spirit {
|
|
4
|
-
constructor(body = {}) {
|
|
5
|
-
this.body = body;
|
|
6
|
-
if (!this.body.route) this.body.route = "/";
|
|
7
|
-
if (!this.body.service) this.body.service = "default";
|
|
8
|
-
if (!this.body.scope) this.body.scope = "global";
|
|
9
|
-
if (!this.body.parent) this.body.parent = null;
|
|
10
|
-
if (!this.body._lastUpdate) this.body._lastUpdate = 0;
|
|
11
|
-
if (!this.body.data) this.body.data = {};
|
|
12
|
-
this.memory = {
|
|
13
|
-
data: {}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
4
|
static db = mongoose.model('spirits', new mongoose.Schema({
|
|
18
5
|
_lastUpdate: Number,
|
|
19
6
|
route: String,
|
|
@@ -27,133 +14,108 @@ export default class Spirit {
|
|
|
27
14
|
data: {}
|
|
28
15
|
}));
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
17
|
+
static buildQuery = (options = {}, data = {}, id = null) => {
|
|
18
|
+
let query = {};
|
|
19
|
+
|
|
20
|
+
if (id) query = {
|
|
21
|
+
_id: id
|
|
22
|
+
};
|
|
23
|
+
if (options) query = {
|
|
24
|
+
...query,
|
|
25
|
+
...options
|
|
26
|
+
};
|
|
27
|
+
if (data){
|
|
28
|
+
let keys = Object.keys(data);
|
|
29
|
+
for (let i = 0; i < keys.length; i++) {
|
|
30
|
+
query[`data.${keys[i]}`] = data[keys[i]];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return query;
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
scope: this.body.scope,
|
|
52
|
-
parent: this.body.parent
|
|
53
|
-
}, {
|
|
54
|
-
route: this.body.route,
|
|
55
|
-
service: this.body.service,
|
|
56
|
-
scope: this.body.scope,
|
|
57
|
-
parent: this.body.parent,
|
|
58
|
-
_lastUpdate: this.time,
|
|
37
|
+
static create = async (options, data) => {
|
|
38
|
+
let spirit = new Spirit();
|
|
39
|
+
|
|
40
|
+
spirit.memory = await Spirit.db.create({
|
|
41
|
+
...options,
|
|
42
|
+
_lastUpdate: Date.now(),
|
|
59
43
|
data: data
|
|
60
|
-
}, {
|
|
61
|
-
upsert: true
|
|
62
44
|
});
|
|
63
45
|
|
|
64
|
-
return
|
|
46
|
+
return spirit;
|
|
65
47
|
}
|
|
66
48
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.memory = await Spirit.db.updateOne({
|
|
71
|
-
route: this.body.route,
|
|
72
|
-
service: this.body.service,
|
|
73
|
-
scope: this.body.scope,
|
|
74
|
-
parent: this.body.parent
|
|
75
|
-
}, {
|
|
76
|
-
route: this.body.route,
|
|
77
|
-
service: this.body.service,
|
|
78
|
-
scope: this.body.scope,
|
|
79
|
-
parent: this.body.parent,
|
|
80
|
-
_lastUpdate: this.time,
|
|
81
|
-
data: data
|
|
82
|
-
}, {
|
|
83
|
-
upsert: true
|
|
84
|
-
}).where(`data.${which}`).equals(query);
|
|
49
|
+
static recall = async (options = {}, data = {}, id = null) => {
|
|
50
|
+
let spirit = new Spirit();
|
|
85
51
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
recall = async () => {
|
|
90
|
-
let found = await Spirit.db.findOne({
|
|
91
|
-
route: this.body.route,
|
|
92
|
-
service: this.body.service,
|
|
93
|
-
scope: this.body.scope,
|
|
94
|
-
parent: this.body.parent
|
|
95
|
-
});
|
|
52
|
+
let query = Spirit.buildQuery(options, data, id);
|
|
53
|
+
|
|
54
|
+
let found = await Spirit.db.find(query);
|
|
96
55
|
|
|
97
|
-
if (found
|
|
98
|
-
|
|
99
|
-
|
|
56
|
+
if (found) {
|
|
57
|
+
spirit.memory = found;
|
|
58
|
+
if (!spirit.memory.data) spirit.memory.data = {};
|
|
100
59
|
|
|
101
|
-
return
|
|
60
|
+
return spirit;
|
|
102
61
|
}
|
|
103
|
-
else return
|
|
62
|
+
else return null;
|
|
104
63
|
}
|
|
105
64
|
|
|
106
|
-
|
|
107
|
-
let
|
|
108
|
-
route: this.body.route,
|
|
109
|
-
service: this.body.service,
|
|
110
|
-
scope: this.body.scope
|
|
111
|
-
});
|
|
65
|
+
static recallOne = async (options = {}, data = {}, id = null) => {
|
|
66
|
+
let spirit = new Spirit();
|
|
112
67
|
|
|
113
|
-
|
|
114
|
-
this.memory = found;
|
|
115
|
-
this.time = found._lastUpdate;
|
|
68
|
+
let query = Spirit.buildQuery(options, data, id);
|
|
116
69
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
70
|
+
let found = await Spirit.db.findOne(query);
|
|
71
|
+
|
|
72
|
+
if (found) {
|
|
73
|
+
spirit.memory = found;
|
|
74
|
+
if (!spirit.memory.data) spirit.memory.data = {};
|
|
121
75
|
|
|
122
|
-
return
|
|
76
|
+
return spirit;
|
|
123
77
|
}
|
|
124
|
-
else return
|
|
78
|
+
else return null;
|
|
125
79
|
}
|
|
126
80
|
|
|
127
|
-
|
|
128
|
-
let
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
81
|
+
static recallOrCreate = async (options = {}, queryData = {}, initdata = {}) => {
|
|
82
|
+
let spirit = new Spirit();
|
|
83
|
+
|
|
84
|
+
let query = Spirit.buildQuery(options, queryData);
|
|
85
|
+
|
|
86
|
+
let found = await Spirit.db.findOne(query);
|
|
132
87
|
|
|
133
|
-
if (found
|
|
134
|
-
|
|
135
|
-
|
|
88
|
+
if (found) {
|
|
89
|
+
spirit.memory = found;
|
|
90
|
+
if (!spirit.memory.data) spirit.memory.data = {};
|
|
136
91
|
|
|
137
|
-
return
|
|
92
|
+
return spirit;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
let newSpirit = await Spirit.create(options, initdata);
|
|
96
|
+
return newSpirit;
|
|
138
97
|
}
|
|
139
|
-
else return false;
|
|
140
98
|
}
|
|
141
99
|
|
|
142
|
-
delete = async () => {
|
|
143
|
-
await Spirit.db.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
100
|
+
static delete = async (options = {}, data = {}, id = null) => {
|
|
101
|
+
let found = await Spirit.db.findAndDelete(Spirit.buildQuery(options, data, id));
|
|
102
|
+
|
|
103
|
+
return found.deletedCount;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
constructor() {
|
|
107
|
+
this.memory = {
|
|
108
|
+
data: {}
|
|
109
|
+
};
|
|
149
110
|
}
|
|
150
111
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
112
|
+
commit = async (data = this.memory.data) => {
|
|
113
|
+
this.memory._lastUpdate = Date.now();
|
|
114
|
+
|
|
115
|
+
this.memory.data = data;
|
|
116
|
+
this.memory.markModified("data");
|
|
117
|
+
await this.memory.save();
|
|
118
|
+
|
|
119
|
+
return "Updated";
|
|
158
120
|
}
|
|
159
121
|
};
|