notherbase-fs 1.4.1 → 1.4.2

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.
@@ -9,25 +9,6 @@ const explorer = async function explorer(worldPath, voidPath) {
9
9
  try {
10
10
  let currentAreaRoute = `${req.params.region}/${req.params.area}/${req.params.poi}`;
11
11
  let currentRoute = `${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
12
-
13
- if (await db.poi.exists({ route: currentRoute, type: "global" }) === false) {
14
- await db.poi.create({
15
- route: currentRoute,
16
- name: req.params.detail,
17
- type: "global",
18
- data: {}
19
- });
20
- }
21
-
22
- if (await db.poi.exists({ route: currentRoute, user: req.session.currentUser }) === false) {
23
- await db.poi.create({
24
- route: currentRoute,
25
- name: req.params.detail,
26
- type: "user",
27
- user: req.session.currentUser,
28
- data: {}
29
- });
30
- }
31
12
 
32
13
  let scriptResult = await require(`${worldPath}/${currentAreaRoute}/server-scripts/${req.params.script}.js`)(db, currentRoute, req.session.currentUser, req.body);
33
14
  res.send({ scriptResult: scriptResult });
@@ -84,7 +65,6 @@ const explorer = async function explorer(worldPath, voidPath) {
84
65
 
85
66
  router.post(`/commit`, async function(req, res) {
86
67
  try {
87
- console.log(req.body);
88
68
  await db.detail.updateOne({
89
69
  route: req.body.route,
90
70
  service: req.body.service,
@@ -137,7 +117,7 @@ const explorer = async function explorer(worldPath, voidPath) {
137
117
  user: null,
138
118
  inventory: null,
139
119
  main: `${voidPath}/index`,
140
- route: `/void/index`
120
+ route: `/void`
141
121
  });
142
122
  }
143
123
  }
@@ -163,7 +143,7 @@ const explorer = async function explorer(worldPath, voidPath) {
163
143
  inventory: foundInventory,
164
144
  query: req.query,
165
145
  dir: worldPath,
166
- route: `/${req.params.region}/${req.params.area}/${req.params.poi}/index`
146
+ route: `/${req.params.region}/${req.params.area}/${req.params.poi}`
167
147
  }
168
148
 
169
149
  await res.render(`explorer`, context);
@@ -175,7 +155,7 @@ const explorer = async function explorer(worldPath, voidPath) {
175
155
  user: null,
176
156
  inventory: null,
177
157
  main: `${voidPath}/index`,
178
- route: `/void/index`
158
+ route: `/void`
179
159
  });
180
160
  }
181
161
  }
@@ -198,7 +178,7 @@ const explorer = async function explorer(worldPath, voidPath) {
198
178
  user: null,
199
179
  inventory: null,
200
180
  main: `${voidPath}/index`,
201
- route: `/void/index`
181
+ route: `/void`
202
182
  });
203
183
  });
204
184
 
@@ -5,21 +5,8 @@ const front = async function front(dir) {
5
5
  let router = require("express").Router();
6
6
 
7
7
  router.post(`/serve/:script`, async function(req, res) {
8
- try {
9
- let currentRoute = `/${req.params.region}/${req.params.area}/${req.params.poi}/${req.params.detail}`;
10
-
11
- let foundPoi = await db.poi.findOne({ route: currentRoute, type: "global" });
12
-
13
- if (foundPoi === null) {
14
- db.poi.create({
15
- route: currentRoute,
16
- name: req.params.detail,
17
- type: "global",
18
- global: {}
19
- });
20
- }
21
-
22
- let scriptResult = await require(`${worldPath}/${currentRoute}/server-scripts/${req.params.script}.js`)(db, currentRoute, req.session.currentUser, req.body);
8
+ try {
9
+ let scriptResult = await require(`${worldPath}/${currentRoute}/server-scripts/${req.params.script}.js`)(db, "/the-front", req.session.currentUser, req.body);
23
10
  res.send(scriptResult);
24
11
  }
25
12
  catch(err) {
@@ -39,7 +26,6 @@ const front = async function front(dir) {
39
26
  siteTitle: `NotherBase - ${req.params.detail}`,
40
27
  user: foundUser,
41
28
  main: main,
42
- pov: req.query.pov,
43
29
  inventory: foundInventory,
44
30
  query: req.query,
45
31
  dir: dir,
@@ -65,11 +51,10 @@ const front = async function front(dir) {
65
51
  siteTitle: `NotherBase - The Front`,
66
52
  user: foundUser,
67
53
  main: main,
68
- pov: req.query.pov,
69
54
  inventory: foundInventory,
70
55
  query: req.query,
71
56
  dir: dir,
72
- route: `/the-front/${req.params.detail}`
57
+ route: `/the-front`
73
58
  }
74
59
 
75
60
  await res.render(`explorer`, context);
package/models/item.js CHANGED
@@ -4,7 +4,10 @@ const mongoose = require("mongoose");
4
4
  const item = new mongoose.Schema({
5
5
  name: String,
6
6
  shortDescription: String,
7
- fullDescription: String
7
+ fullDescription: String,
8
+ icon: String,
9
+ tags: [ String ],
10
+ image: String
8
11
  });
9
12
 
10
13
  // This tells Mongoose to use the exampleSchema to access the examples collection
@@ -21,6 +21,28 @@ const passwordReset = async (toEmail, resetToken) => {
21
21
  });
22
22
  };
23
23
 
24
+ const send = async (toEmail, subject, html) => {
25
+ var transporter = nodemailer.createTransport({
26
+ service: 'gmail',
27
+ auth: {
28
+ user: process.env.NOREPLY,
29
+ pass: process.env.NOREPLYPW
30
+ }
31
+ });
32
+
33
+ var mailOptions = {
34
+ from: process.env.NOREPLY,
35
+ to: toEmail,
36
+ subject: subject,
37
+ html: html
38
+ };
39
+
40
+ return await transporter.sendMail(mailOptions, function(error, info){
41
+ if (error) console.log(error);
42
+ });
43
+ }
44
+
24
45
  module.exports = {
25
- passwordReset: passwordReset
46
+ passwordReset: passwordReset,
47
+ send: send
26
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "main": "notherbase-fs.js",
6
6
  "scripts": {
@@ -0,0 +1,9 @@
1
+ module.exports = async function addToTimer(db, route, user, params) {
2
+ try {
3
+ return await db.sendMail.send(params.toEmail, params.subject, params.html);
4
+ }
5
+ catch(err) {
6
+ console.log(err);
7
+ return false;
8
+ }
9
+ }
@@ -21,6 +21,7 @@
21
21
 
22
22
  <button onclick="setTime()">Add</button>
23
23
  <p id="timer">0:00</p>
24
+ <button onclick="emailTime()">email</button>
24
25
 
25
26
  <hr>
26
27
 
@@ -134,5 +135,15 @@
134
135
  $("#timer").text(Math.floor((Date.now() - time) / 1000));
135
136
  }
136
137
 
138
+ let emailTime = async () => {
139
+ $.post("/coast/tall-beach/nono-cove/index/serve/emailTime", {
140
+ toEmail: "wyattsushi@gmail.com",
141
+ subject: "New Time Update!",
142
+ html: `New Time: ${time}`
143
+ }, (res) => {
144
+ console.log(res);
145
+ })
146
+ }
147
+
137
148
  setInterval(updateTime, 1000);
138
149
  </script>
package/views/more.ejs CHANGED
@@ -12,7 +12,7 @@
12
12
  $("#send").on("click", (e) => {
13
13
  $.post("/contact",
14
14
  {
15
- location: "Test",
15
+ location: currentRoute,
16
16
  content: $("#content").val(),
17
17
  },
18
18
  function () {
@@ -1,31 +0,0 @@
1
- module.exports = async function addToTimer(db, route, user, params) {
2
- try {
3
- let poi = await db.poi.findOne({ route: route, user: user });
4
-
5
- let now = Date.now();
6
-
7
- if (!poi.data) poi.data = {
8
- timer: 0,
9
- lastTime: now
10
- }
11
- else {
12
- if (!poi.data.lastTime) poi.data.lastTime = now;
13
- if (!poi.data.timer) poi.data.timer = 0;
14
- }
15
-
16
- let difference = (now - poi.data.lastTime) / 1000;
17
- poi.data.timer -= difference;
18
- if (poi.data.timer < 0) poi.data.timer = 0;
19
-
20
- poi.data.timer = poi.data.timer + 10;
21
- poi.data.lastTime = Date.now();
22
-
23
- poi.markModified("data");
24
- await poi.save();
25
- return poi.data.timer;
26
- }
27
- catch(err) {
28
- console.log(err);
29
- return false;
30
- }
31
- }