@vulkano/core 0.6.0 → 0.8.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/app.js CHANGED
@@ -1,8 +1,13 @@
1
+ /* eslint-disable import/no-dynamic-require */
2
+
1
3
  /**
2
4
  * Bootstrap.js
3
5
  *
4
6
  */
5
7
 
8
+ // Start Time for logs
9
+ global.START_TIME = new Date();
10
+
6
11
  const dotenv = require('dotenv');
7
12
  const path = require('path');
8
13
  const moment = require('moment');
@@ -16,19 +21,34 @@ global.app = {};
16
21
  global._ = _;
17
22
  global.Promise = Promise;
18
23
 
24
+ const rootProject = path.resolve(process.cwd());
25
+
26
+ // Set the ABS_PATH
19
27
  if (!global.ABS_PATH) {
20
- global.ABS_PATH = path.resolve(__dirname, './');
28
+ global.ABS_PATH = path.resolve(rootProject, './');
21
29
  }
22
30
 
31
+ // Set the APP_PATH
23
32
  if (!global.APP_PATH) {
24
- global.APP_PATH = path.join(__dirname, './');
33
+ global.APP_PATH = path.resolve(rootProject, './app');
34
+ if (!fs.existsSync(APP_PATH)) {
35
+ global.APP_PATH = path.resolve(rootProject, './');
36
+ }
37
+ }
38
+
39
+ if (!fs.existsSync(APP_PATH)) {
40
+ console.log('the global var APP_PATH or directory not found', APP_PATH);
41
+ global.APP_PATH = path.resolve(__dirname, './');
25
42
  }
26
43
 
27
44
  if (!global.PUBLIC_PATH) {
28
- global.PUBLIC_PATH = path.join(__dirname, './');
45
+ global.PUBLIC_PATH = path.resolve(rootProject, './public');
46
+ if (!fs.existsSync(PUBLIC_PATH)) {
47
+ global.PUBLIC_PATH = path.resolve(rootProject, './');
48
+ }
29
49
  }
30
50
 
31
- global.CORE_PATH = path.join(__dirname, './');
51
+ global.CORE_PATH = __dirname;
32
52
 
33
53
  if (!fs.existsSync(APP_PATH)) {
34
54
  console.log('the global var APP_PATH or directory not found', APP_PATH);
@@ -50,7 +70,9 @@ const config = require('include-all')({
50
70
  optional: true
51
71
  });
52
72
 
73
+ //
53
74
  // Get package.json information
75
+ //
54
76
  const pkg = require(`${CORE_PATH}/package.json`);
55
77
  const appPkg = require(`${ABS_PATH}/package.json`);
56
78
 
@@ -246,6 +268,6 @@ function startVulkano() {
246
268
 
247
269
  });
248
270
 
249
- };
271
+ }
250
272
 
251
273
  module.exports = startVulkano;
@@ -12,7 +12,6 @@ const multer = require('multer');
12
12
  const helmet = require('helmet');
13
13
  const timeout = require('connect-timeout');
14
14
  const useragent = require('express-useragent');
15
- const webp = require('webp-middleware');
16
15
  const cookieParser = require('cookie-parser');
17
16
  const merge = require('deepmerge');
18
17
  const { createClient } = require('redis');
@@ -150,9 +149,9 @@ module.exports = {
150
149
  // COOKIES - File: app/config/express/cookies.js
151
150
  // ---------------
152
151
  if (expressConfig.cookies && expressConfig.cookies.enabled) {
153
- const cookiesSecretKey = expressConfig.cookies && expressConfig.cookies.secret ? expressConfig.cookies.secret : '';
152
+ const cookiesSecretKey = process.env.COOKIES_SECRET_KEY || expressConfig.cookies.key || expressConfig.cookies.secret || '';
154
153
  if (!cookiesSecretKey) {
155
- console.log('Warning: Please set cookie secret key in the file config/express/cookie.js');
154
+ console.log(' \x1b[33mWARNING\x1b[0m: Set the secret key in the config/express/cookie.js file or COOKIES_SECRET_KEY in the .env file.');
156
155
  }
157
156
  server.use(cookieParser(cookiesSecretKey));
158
157
  }
@@ -177,19 +176,6 @@ module.exports = {
177
176
  // ---------------
178
177
  server.use(responses);
179
178
 
180
- // ---------------
181
- // WEBP MIDDLEWARE - File: app/config/express/webp.js
182
- // ---------------
183
- if (expressConfig.webp && expressConfig.webp.enabled) {
184
- const cacheDir = expressConfig.webp.folder || `${PUBLIC_PATH}/webp-cache`;
185
- const webpConfig = {
186
- quality: expressConfig.webp.quality || 80,
187
- preset: expressConfig.webp.preset || 'photo',
188
- cacheDir: expressConfig.webp.cacheDir || cacheDir
189
- };
190
- server.use(webp(PUBLIC_PATH, webpConfig));
191
- }
192
-
193
179
  // ---------------
194
180
  // PUBLIC PATH - File: app/config/settings.js
195
181
  // ---------------
@@ -265,6 +251,12 @@ module.exports = {
265
251
  // ---------------
266
252
  if (expressConfig.jwt && expressConfig.jwt.enabled) {
267
253
 
254
+ const jwtSecretKey = process.env.JWT_SECRET_KEY || expressConfig.jwt.key || expressConfig.jwt.secret || '';
255
+ if (!jwtSecretKey) {
256
+ console.log(' \x1b[41mERROR\x1b[0m: Can not get key in config/express/jwt.js file or JWT_SECRET_KEY in .env file');
257
+ return;
258
+ }
259
+
268
260
  // JWT (secret key)
269
261
  server.use(expressConfig.jwt.path || '*', jwtMiddleware.init().unless({
270
262
  path: expressConfig.jwt.ignore || []
package/bun.lockb CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vulkano/core",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "A MVC framework using Express 4",
5
5
  "license": "MIT",
6
6
  "author": "Vulkano Team",
@@ -60,9 +60,9 @@
60
60
  "promise.prototype.finally": "^3.1.8",
61
61
  "redis": "^4.6.13",
62
62
  "socket.io": "^4.7.5",
63
+ "socket.io-adapter": "^2.5.4",
63
64
  "socket.io-client": "4.7.5",
64
65
  "underscore": "^1.13.6",
65
- "webp-middleware": "^0.4.0",
66
66
  "yargs": "^17.7.2"
67
67
  },
68
68
  "devDependencies": {