notherbase-fs 4.0.18 → 4.0.20

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 (2) hide show
  1. package/notherbase-fs.js +15 -13
  2. package/package.json +1 -1
package/notherbase-fs.js CHANGED
@@ -11,6 +11,7 @@ import SpiritWorld from "./controllers/spirit-world.js";
11
11
  import favicon from 'serve-favicon';
12
12
  import session from 'express-session';
13
13
  import MongoStore from 'connect-mongo';
14
+ import cors from 'cors';
14
15
 
15
16
 
16
17
  /**
@@ -26,16 +27,28 @@ class NotherBaseFS {
26
27
  this.spiritWorld = new SpiritWorld(this.io);
27
28
  this.creation = new Creation(bases);
28
29
 
30
+ //set views path
31
+ this.app.set("view engine", "ejs");
32
+ this.app.set("views", `${__dirname}/views`);
33
+
34
+ // allows us to use post body data
35
+ this.app.use(express.json({
36
+ extended: true,
37
+ inflate: true,
38
+ type: 'application/x-www-form-urlencoded'
39
+ }));
40
+
29
41
  //be safe, needs to be before session
30
42
  if (process.env.PRODUCTION == "true") this.app.set('trust proxy', 1);
43
+
44
+ this.app.use(cors());
31
45
 
32
46
  let baseKeys = Object.keys(this.bases);
33
- let mongoStore = MongoStore.create({ mongoUrl: process.env.MONGODB_URI });
34
47
  for (let i = 0; i < baseKeys.length; i++) {
35
48
  this.bases[baseKeys[i]].static = express.static(this.bases[baseKeys[i]].directory + "/public");
36
49
  this.bases[baseKeys[i]].favicon = favicon(this.bases[baseKeys[i]].directory + this.bases[baseKeys[i]].icon);
37
50
  this.bases[baseKeys[i]].session = session({
38
- store: mongoStore,
51
+ store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI }),
39
52
  secret: process.env.SECRET,
40
53
  name: baseKeys[i] + '-session-id',
41
54
  resave: false,
@@ -48,17 +61,6 @@ class NotherBaseFS {
48
61
  }
49
62
  });
50
63
  }
51
-
52
- //set views path
53
- this.app.set("view engine", "ejs");
54
- this.app.set("views", `${__dirname}/views`);
55
-
56
- // allows us to use post body data
57
- this.app.use(express.json({
58
- extended: true,
59
- inflate: true,
60
- type: 'application/x-www-form-urlencoded'
61
- }));
62
64
 
63
65
  //provide database access and etc to use in routes
64
66
  this.app.use((req, res, next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "4.0.18",
3
+ "version": "4.0.20",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {