notherbase-fs 1.0.37 → 1.0.41

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.
@@ -0,0 +1,27 @@
1
+ const User = require("./user/models.js").user;
2
+
3
+ const authCheck = async function authCheck(req, res, next){
4
+ try {
5
+ if (req.session.currentUser) {
6
+ const foundAccount = await User.findById(req.session.currentUser);
7
+
8
+ if (foundAccount) {
9
+ req.session.currentUserFull = foundAccount;
10
+ next();
11
+ }
12
+ else {
13
+ req.session.currentUserFull = null;
14
+ res.redirect("/the-front");
15
+ }
16
+ }
17
+ else{
18
+ res.redirect("/the-front");
19
+ }
20
+ }
21
+ catch(err) {
22
+ console.log("database error");
23
+ console.log(err);
24
+ }
25
+ }
26
+
27
+ module.exports = authCheck;
@@ -0,0 +1,30 @@
1
+ const express = require("express");
2
+ const router = express.Router();
3
+
4
+ const getRouterWithIO = function getRouterWithIO(io) {
5
+ router.post("/", async function(req, res) {
6
+ try {
7
+ //const foundAccount = await User.findOne({ _id: req.session.currentUser });
8
+
9
+ if (req.session.currentUserFull) {
10
+ io.to(req.body.room).emit('chat message', {
11
+ name: req.session.currentUserFull.username,
12
+ time: Date.now(),
13
+ text: req.body.text
14
+ });
15
+
16
+ res.status(200).end();
17
+ }
18
+ else {
19
+ res.status(401).end();
20
+ }
21
+ }
22
+ catch(err) {
23
+ console.log(err);
24
+ }
25
+ });
26
+
27
+ return router;
28
+ }
29
+
30
+ module.exports = getRouterWithIO;
@@ -0,0 +1,22 @@
1
+ const express = require("express");
2
+ const router = express.Router();
3
+
4
+ const contact = require(process.cwd() + "/models/contact");
5
+
6
+ router.post("/", async function(req, res) {
7
+ try {
8
+ await contact.create({
9
+ user: req.session.currentUser,
10
+ location: req.body.location,
11
+ content: req.body.content
12
+ });
13
+
14
+ res.status(200).end();
15
+ }
16
+ catch(err) {
17
+ res.status(500).end();
18
+ console.log(err);
19
+ }
20
+ });
21
+
22
+ module.exports = router;
@@ -0,0 +1,122 @@
1
+ const inventory = require("../models/inventory");
2
+
3
+ let router = require("express").Router();;
4
+ let dir = "";
5
+
6
+ let complete = function complete(explorerBuild) {
7
+ dir = explorerBuild.dirname;
8
+
9
+ let currentRegion, currentArea, currentPoi = "";
10
+
11
+ for (let i = 0; i < explorerBuild.regions.length; i++) {
12
+ let region = explorerBuild.regions[i];
13
+ currentRegion = region.name;
14
+
15
+ for (let j = 0; j < region.areas.length; j++) {
16
+ let area = region.areas[j];
17
+ currentArea = area.name;
18
+
19
+ for (let k = 0; k < area.pois.length; k++) {
20
+ let poi = area.pois[k];
21
+ currentPoi = poi.name;
22
+
23
+ for (let l = 0; l < poi.details.length; l++) {
24
+ let detail = poi.details[l];
25
+
26
+ let currentDir = `${dir}/${currentRegion}/${currentArea}/${currentPoi}`;
27
+
28
+ detail.options = {
29
+ styles: [],
30
+ externalStyles: [],
31
+ scripts: [],
32
+ needsKey: "",
33
+ dropOff: "",
34
+ ...detail.options
35
+ };
36
+
37
+ detail.options.styles = detail.options.styles.map(style => {
38
+ style = `${currentDir}/styles/${style}`;
39
+ return style;
40
+ });
41
+
42
+ detail.options.externalStyles = detail.options.externalStyles.map(style => {
43
+ style = `${currentDir}/${style}`;
44
+ return style;
45
+ });
46
+
47
+ detail.options.scripts = detail.options.scripts.map(script => {
48
+ script = `${currentDir}/local-scripts/${script}`;
49
+ return script;
50
+ });
51
+
52
+ detail.options.main = "index";
53
+ if (detail.route !== "") detail.options.main = route;
54
+ detail.options.main = `${currentDir}/views/${detail.options.main}`;
55
+
56
+ router.get(`${currentDir}/${detail.route}`, async function(req, res) {
57
+ try {
58
+ const foundInventory = await inventory.findOne({ user: req.session.currentUser }).populate("items.item");
59
+
60
+ if (detail.options.needsKey !== "" && foundInventory) {
61
+ let hasKey = false;
62
+
63
+ for (let i = 0; i < foundInventory.items.length; i++) {
64
+ if (foundInventory.items[i].item.name === detail.options.needsKey) hasKey = true;
65
+ }
66
+
67
+ if (!hasKey) res.redirect(detail.options.dropOff);
68
+ else res.render(`explorer`,
69
+ {
70
+ siteTitle: "NotherBase",
71
+ user: req.session.currentUserFull,
72
+ styles: detail.options.styles,
73
+ externalStyles: detail.options.externalStyles,
74
+ main: detail.options.main,
75
+ scripts: detail.options.scripts,
76
+ pov: req.query.pov,
77
+ inventory: foundInventory,
78
+ query: req.query
79
+ });
80
+ }
81
+ else res.render(`explorer`,
82
+ {
83
+ siteTitle: "NotherBase",
84
+ user: req.session.currentUserFull,
85
+ styles: detail.options.styles,
86
+ externalStyles: detail.options.externalStyles,
87
+ main: detail.options.main,
88
+ scripts: detail.options.scripts,
89
+ pov: req.query.pov,
90
+ inventory: foundInventory,
91
+ query: req.query
92
+ });
93
+ }
94
+ catch(err) {
95
+ console.log(err);
96
+ }
97
+ });
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+
104
+ //the void
105
+ router.use(function(req, res, next){
106
+ res.render(`${dir}/${explorerBuild.void}/index`,
107
+ {
108
+ siteTitle: "NotherBase",
109
+ user: null
110
+ });
111
+ });
112
+
113
+ // start location
114
+ router.get("/", function(req, res) {
115
+ res.redirect("/the-front");
116
+ });
117
+ }
118
+
119
+ module.exports = {
120
+ router: router,
121
+ complete: complete
122
+ }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ chat: require("chat"),
3
+ item: require("item"),
4
+ portfolio: require("./portfolio/portfolio-controller.js"),
5
+ user: require("user"),
6
+ authCheck: require("authCheck"),
7
+ contact: require("contact"),
8
+ explorer: require("explorer"),
9
+ front: require("the-front"),
10
+ inventory: require("inventory")
11
+ }
@@ -0,0 +1,104 @@
1
+ const express = require("express");
2
+ const router = express.Router();
3
+
4
+ // Import my Data
5
+ const inventory = require(process.cwd() + "/models/inventory");
6
+ const item = require(process.cwd() + "/models/item");
7
+
8
+ router.get("/", async function(req, res) {
9
+ try {
10
+ if (req.session.currentUserFull) {
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
+ }
22
+ });
23
+
24
+ router.post("/", async function(req, res) {
25
+ try {
26
+ if (req.session.currentUserFull) {
27
+ let foundInventory = await inventory.findOne({user: req.session.currentUser}).populate("items.item");
28
+
29
+ let holding = false;
30
+
31
+ for (let j = 0; j < foundInventory.items.length; j++) {
32
+ if (foundInventory.items[j].item._id.equals(req.body.change.item)) {
33
+ holding = true;
34
+
35
+ if (foundInventory.items[j].amount >= -Math.floor(req.body.change.amount)) {
36
+ foundInventory.items[j].amount += Math.floor(req.body.change.amount);
37
+
38
+ if (foundInventory.items[j].amount === 0) {
39
+ let itemToEmpty = foundInventory.items[j].item._id;
40
+
41
+ foundInventory.items.splice(j, 1);
42
+ await foundInventory.save();
43
+
44
+ res.status(200).send({
45
+ item: {
46
+ _id: itemToEmpty
47
+ },
48
+ amount: 0
49
+ });
50
+ }
51
+ else {
52
+ await foundInventory.save();
53
+
54
+ res.status(200).send(foundInventory.items[j]);
55
+ }
56
+ }
57
+ else {
58
+ console.log("subtract from too few", req.body.change);
59
+ res.status(304).send(
60
+ `Unable to remove ${req.body.change.amount} ${req.body.change.item}
61
+ from inventory because the inventory has only ${foundInventory.items[j].amount}.`
62
+ );
63
+ }
64
+
65
+ break;
66
+ }
67
+ }
68
+
69
+ if (!holding) {
70
+ if (req.body.change.amount > 0) {
71
+ let foundItem = await item.findById(req.body.change.item);
72
+
73
+ foundInventory.items.push({
74
+ item: foundItem._id,
75
+ amount: req.body.change.amount
76
+ });
77
+
78
+ await foundInventory.save();
79
+
80
+ await inventory.populate(foundInventory, "items.item");
81
+
82
+ res.status(200).send(foundInventory.items[foundInventory.items.length - 1]);
83
+ }
84
+ else {
85
+ console.log("subtract from none", req.body.change);
86
+ res.status(304).send(
87
+ `Unable to remove ${req.body.change.amount} ${req.body.change.item}
88
+ from inventory because the inventory has none.`
89
+ );
90
+ }
91
+ };
92
+ }
93
+ else {
94
+ res.status(401).send("User not logged in!");
95
+ }
96
+ }
97
+ catch(err) {
98
+ res.status(500).end();
99
+ console.log(err);
100
+ }
101
+ });
102
+
103
+
104
+ module.exports = router;
@@ -0,0 +1,61 @@
1
+ const express = require("express");
2
+ const router = express.Router();
3
+
4
+ // Import my Data
5
+ const items = require(process.cwd() + "/models/item");
6
+
7
+ router.get("/all", async function(req, res) {
8
+ try {
9
+ let foundItems = await items.find({});
10
+
11
+ res.status(200).send({ foundItems: foundItems });
12
+ }
13
+ catch(err) {
14
+ res.status(500).end();
15
+ console.log(err);
16
+ }
17
+ });
18
+
19
+ router.get("/findOne", async function(req, res) {
20
+ try {
21
+ let foundItem = await items.findOne({name: req.query.name});
22
+
23
+ if (!foundItem) res.status(500).end();
24
+ else res.status(200).send({ foundItem: foundItem });
25
+ }
26
+ catch(err) {
27
+ res.status(500).end();
28
+ console.log(err);
29
+ }
30
+ });
31
+
32
+ router.get("/", async function(req, res) {
33
+ try {
34
+ let foundItems = await items.find({ name: { $regex: req.query.name } });
35
+
36
+ res.status(200).send({ foundItems: foundItems });
37
+ }
38
+ catch(err) {
39
+ res.status(500).end();
40
+ console.log(err);
41
+ }
42
+ });
43
+
44
+ router.post("/", async function(req, res) {
45
+ try {
46
+ await items.create({
47
+ name: req.body.name,
48
+ shortDescription: req.body.shortDescription,
49
+ fullDescription: req.body.fullDescription
50
+ });
51
+
52
+ res.status(200).end();
53
+ }
54
+ catch(err) {
55
+ res.status(500).end();
56
+ console.log(err);
57
+ }
58
+ });
59
+
60
+
61
+ module.exports = router;
@@ -0,0 +1,16 @@
1
+ const mongoose = require("mongoose");
2
+
3
+ const projects = new mongoose.Schema({
4
+ name: String,
5
+ url: String,
6
+ repository: String,
7
+ description: String,
8
+ thumbnail: String,
9
+ cover: String,
10
+ developers: [{
11
+ type: mongoose.Schema.Types.ObjectId,
12
+ ref: "users"
13
+ }]
14
+ });
15
+
16
+ module.exports = mongoose.model('projects', projects);
@@ -0,0 +1,10 @@
1
+ const express = require("express");
2
+ const router = express.Router();
3
+
4
+ router.get("/", function(req, res) {
5
+ res.render(`${__dirname}/views/index`, {
6
+ siteTitle: "Wyatt's Portfolio"
7
+ });
8
+ });
9
+
10
+ module.exports = router;
@@ -0,0 +1,234 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title><%= siteTitle %></title>
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
+ <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
8
+
9
+ <link rel="preconnect" href="https://fonts.googleapis.com">
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11
+ <link href="https://fonts.googleapis.com/css2?family=Chakra+Petch&display=swap" rel="stylesheet">
12
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
13
+ <link rel="stylesheet" href="/styles/portfolio.css">
14
+ </head>
15
+
16
+ <body>
17
+ <nav class="nav-closed">
18
+ <h1>Wyatt Sushinsky</h1>
19
+
20
+ <div>
21
+ <a href="https://www.linkedin.com/in/wyatt-sushinsky/"><i class="fab fa-linkedin"></i></a>
22
+ <a href="https://github.com/Mosshide"><i class="fab fa-github-square"></i></a>
23
+ </div>
24
+ </nav>
25
+
26
+ <header>
27
+ <div class="portrait">
28
+ <div class="portrait-fade"></div>
29
+ </div>
30
+
31
+ <h2>Wyatt Sushinsky</h2>
32
+
33
+ <h3>Software Engineer</h3>
34
+
35
+ <div class="external-links">
36
+ <a href="https://www.linkedin.com/in/wyatt-sushinsky/"><i class="fab fa-linkedin"></i></a>
37
+ <a href="https://github.com/Mosshide"><i class="fab fa-github-square"></i></a>
38
+ </div>
39
+ </header>
40
+
41
+ <main>
42
+ <section class="showcase" id="notherbase">
43
+ <img src="/img/logo.png" />
44
+
45
+ <div class="text">
46
+ <h3>NotherBase</h3>
47
+
48
+ <h4>
49
+ <a target="_blank" href="https://github.com/Mosshide/NotherBase">
50
+ <i class="fab fa-github-square"></i>Repository
51
+ </a>
52
+
53
+ <a target="_blank" href="https://www.notherbase.com/">
54
+ <i class="fas fa-external-link-square-alt"></i>Live App
55
+ </a>
56
+ </h4>
57
+
58
+ <hr>
59
+
60
+ <p>
61
+ Welcome to NotherBase! This is my web app playground.
62
+ Explore the world of NotherBase and unlock its secrets.
63
+ </p>
64
+
65
+ <p>
66
+ This app is currently in development.
67
+ </p>
68
+ </div>
69
+ </section>
70
+
71
+ <section class="showcase" id="notherbase-fs">
72
+ <img src="/img/logo.png" />
73
+
74
+ <div class="text">
75
+ <h3>notherbase-fs</h3>
76
+
77
+ <h4>
78
+ <a target="_blank" href="https://github.com/Mosshide/notherbase-fs">
79
+ <i class="fab fa-github-square"></i>Repository
80
+ </a>
81
+
82
+ <a target="_blank" href="https://www.npmjs.com/package/notherbase-fs">
83
+ <i class="fas fa-external-link-square-alt"></i>Latest Release
84
+ </a>
85
+ </h4>
86
+
87
+ <hr>
88
+
89
+ <p>
90
+ This is a Node.js package that is in development along with NotherBase.
91
+ It adapts Express.js so I can produce content quicker.
92
+ </p>
93
+ </div>
94
+ </section>
95
+
96
+ <section class="showcase" id="cpd">
97
+ <img src="/img/cpd_ss.jpg" />
98
+
99
+ <div class="text">
100
+ <h3>Cannabis Product Diary</h3>
101
+
102
+ <h4>
103
+ <a target="_blank" href="https://github.com/Mosshide/cannabis-product-diary">
104
+ <i class="fab fa-github-square"></i>Repository
105
+ </a>
106
+
107
+ <a target="_blank" href="https://cpd.notherbase.com/">
108
+ <i class="fas fa-external-link-square-alt"></i>Live App
109
+ </a>
110
+ </h4>
111
+
112
+ <hr>
113
+
114
+ <p>
115
+ Cannabis Product Diary helps you keep track of your purchased cannabis products and
116
+ the experiences garnered from these products. I find that large sites like Leafly
117
+ fail to provide any accurate information about the products at local dispensaries,
118
+ so this app is useful for anyone wanting to keep track of details about the local
119
+ products they've purchased.
120
+ </p>
121
+
122
+ <p>
123
+ This app is currently in development.
124
+ </p>
125
+ </div>
126
+ </section>
127
+
128
+ <section class="showcase" id="tamago-watch">
129
+ <%- include("parts/tamago.ejs"); %>
130
+
131
+ <div class="text">
132
+ <h3>Tamago Watch</h3>
133
+
134
+ <h4>
135
+ <a target="_blank" href="https://github.com/Mosshide/tamago-watch">
136
+ <i class="fab fa-github-square"></i>Repository
137
+ </a>
138
+
139
+ <a target="_blank" href="https://mosshide.github.io/tamago-watch/">
140
+ <i class="fas fa-external-link-square-alt"></i>Live App
141
+ </a>
142
+ </h4>
143
+
144
+ <hr class="light">
145
+
146
+ <p>
147
+ Tamago Watch is a virtual toy based off the classic Tamagotchi toy. I focused on
148
+ making this toy rigid and consistent, so that it may invoke the feeling of real-life
149
+ hardware. Just like the real toy, the Tamago Watch is arguably more fun to discover
150
+ than to actually play for any extended period of time.
151
+ </p>
152
+
153
+ <p>
154
+ This app is has been released and no future updates are planned.
155
+ </p>
156
+ </div>
157
+ </section>
158
+
159
+ <section class="showcase" id="won-ventures">
160
+ <img src="/img/wv_ss.jpg" />
161
+
162
+ <div class="text">
163
+ <h3>Won Ventures</h3>
164
+
165
+ <h4>
166
+ <a target="_blank" href="https://github.com/Mosshide/won-ventures">
167
+ <i class="fab fa-github-square"></i>Repository
168
+ </a>
169
+
170
+ <a target="_blank" href="https://won-ventures.herokuapp.com/">
171
+ <i class="fas fa-external-link-square-alt"></i>Live App
172
+ </a>
173
+ </h4>
174
+
175
+ <hr>
176
+
177
+ <p>
178
+ Won Ventures is a stock-trading site built by
179
+ <a href="https://www.linkedin.com/in/jonathanmichaelpark/">Jon Park</a> and myself.
180
+ The project is a practice on reverse-engineering CRUD functionality from other
181
+ sites. In this case, we modeled after sites like Robinhood. A large focus was
182
+ gaining collaboration experience. This was fun team project and it was
183
+ a pleasure to work with Jon.
184
+ </p>
185
+
186
+ <p>
187
+ This app is has been released and no future updates are planned.
188
+ </p>
189
+ </div>
190
+ </section>
191
+
192
+ <section class="showcase" id="wayfarer">
193
+ <img src="/img/wf_ss.jpg" />
194
+
195
+ <div class="text">
196
+ <h3>Wayfarer</h3>
197
+
198
+ <h4>
199
+ <a target="_blank" href="https://github.com/Mosshide/wayfarer">
200
+ <i class="fab fa-github-square"></i>Repository
201
+ </a>
202
+ </h4>
203
+
204
+ <hr class="light">
205
+
206
+ <p>
207
+ A city park and travelling app. The focus of this project was meeting client
208
+ timelines and expectations. My team(
209
+ <a href="https://www.linkedin.com/in/lesley-sauter-45372437/">Lesley Sauter</a>
210
+ and <a href="https://www.linkedin.com/in/scott-sperry0409/">Scott Perry</a>) and I
211
+ would meet with the client and fulfill planned sprints. We adhered to our client's
212
+ user stories and wireframes, and communicated effectively with the client to ensure
213
+ they were satisfied with our work.
214
+ </p>
215
+
216
+ <p>
217
+ This app is has not been deployed as of yet and no future updates are planned.
218
+ </p>
219
+ </div>
220
+ </section>
221
+ </main>
222
+
223
+ <script>
224
+ $(window).scroll(function() {
225
+ if (window.scrollY > (3 / 4) * parseInt($("header").css("height"))) {
226
+ $("nav").removeClass("nav-closed");
227
+ }
228
+ else {
229
+ $("nav").addClass("nav-closed");
230
+ }
231
+ });
232
+ </script>
233
+ </body>
234
+ </html>