notherbase-fs 3.0.1 → 3.0.3

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.
@@ -11,7 +11,7 @@ export default class Creation {
11
11
  this.router.get(`/the-front`, this.explore);
12
12
  this.router.get(`/the-front/:frontDetail`, this.explore);
13
13
  //pages
14
- this.router.get(`/:page`, this.explore);
14
+ this.router.get(`/:page`, this.page);
15
15
  //explorer
16
16
  this.router.get(`/:region/:area/:poi`, this.lock, this.explore);
17
17
  this.router.get(`/:region/:area/:poi/:detail`, this.lock, this.explore);
@@ -85,4 +85,40 @@ export default class Creation {
85
85
  res.status(500).end();
86
86
  }
87
87
  }
88
+
89
+ page = async (req, res, next) => {
90
+ let main = `${req.contentPath}`;
91
+
92
+ main += `/${req.params.page}/index.ejs`;
93
+
94
+ try {
95
+ if (fs.existsSync(main)) {
96
+ let user = await req.db.User.recallOne(req.session.currentUser);
97
+
98
+ let userStuff = {
99
+ userID: null,
100
+ user: null
101
+ };
102
+
103
+ if (user) userStuff = {
104
+ userID: user.id,
105
+ user: user.memory.data
106
+ };
107
+
108
+ let context = {
109
+ ...userStuff,
110
+ query: req.query,
111
+ dir: req.frontDir,
112
+ route: req.path
113
+ }
114
+
115
+ res.render(main, context);
116
+ }
117
+ else next();
118
+ }
119
+ catch(err) {
120
+ console.log(err);
121
+ res.status(500).end();
122
+ }
123
+ }
88
124
  }
package/models/index.js CHANGED
@@ -63,11 +63,30 @@ catch (err) {
63
63
 
64
64
  // user.find({}, async (err, users) => {
65
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
- // );
66
+ // let userSpirit = await Spirit.create({
67
+ // route: "/",
68
+ // service: "user",
69
+ // scope: "global",
70
+ // parent: null,
71
+ // _lastUpdate: Date.now()
72
+ // }, {
73
+ // username: users[i].username,
74
+ // password: users[i].password,
75
+ // email: users[i].email,
76
+ // resetToken: null,
77
+ // resetExp: null,
78
+ // coin: 0,
79
+ // home: "/",
80
+ // authLevels: [ "Basic" ],
81
+ // location: "/the-front",
82
+ // attributes: {
83
+ // translation: 0,
84
+ // strength: 0,
85
+ // agility: 0,
86
+ // defense: 0
87
+ // },
88
+ // inventory: []
89
+ // });
71
90
 
72
91
  // let foundPages = await page.find({ user: users[i]._id });
73
92
 
package/models/spirit.js CHANGED
@@ -92,6 +92,7 @@ export default class Spirit {
92
92
  return spirit;
93
93
  }
94
94
  else {
95
+ options._lastUpdate = Date.now();
95
96
  let newSpirit = await Spirit.create(options, initdata);
96
97
  return newSpirit;
97
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
@@ -6,7 +6,7 @@ class Base {
6
6
 
7
7
  await $.post(route, JSON.stringify(body), (res) => {
8
8
  response = res;
9
- if (res.status != "success") console.log(`${route} - ${res}`);
9
+ if (res.status != "success") console.log(`${route} - ${res.message}`);
10
10
  });
11
11
 
12
12
  return response;