hola-server 0.6.1 → 0.6.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.
package/core/validate.js CHANGED
@@ -3,7 +3,9 @@ const is_undefined = function (value) {
3
3
  }
4
4
 
5
5
  const has_value = function (value) {
6
- if (value === undefined || value === null || isNaN(value)) {
6
+ //In short, JavaScript NaN values are the only ones that are not equal to themselves
7
+ //value!==value is to check is NaN
8
+ if (value === undefined || value === null || value !== value) {
7
9
  return false
8
10
  }
9
11
  if (typeof value == 'undefined') {
package/http/cors.js CHANGED
@@ -3,11 +3,13 @@ const { get_settings } = require('../setting');
3
3
 
4
4
  const init_cors = (app) => {
5
5
  const server = get_settings().server;
6
- app.use(cors({
7
- origin: server.client_web_url,
8
- methods: ['GET', 'POST'],
9
- credentials: true
10
- }));
6
+ if (server && server.client_web_url) {
7
+ app.use(cors({
8
+ origin: server.client_web_url,
9
+ methods: ['GET', 'POST'],
10
+ credentials: true
11
+ }));
12
+ }
11
13
  }
12
14
 
13
15
  module.exports = { init_cors };
package/http/express.js CHANGED
@@ -32,8 +32,12 @@ const init_express_server = (base_dir, port_attr, callback) => {
32
32
  const threshold = server.threshold;
33
33
 
34
34
  init_cors(app);
35
- app.use(express.json({ limit: threshold.body_limit, extended: true }));
36
- app.use(express.urlencoded({ limit: threshold.body_limit, extended: true }));
35
+
36
+ if (threshold) {
37
+ app.use(express.json({ limit: threshold.body_limit, extended: true }));
38
+ app.use(express.urlencoded({ limit: threshold.body_limit, extended: true }));
39
+ }
40
+
37
41
  init_session(app);
38
42
 
39
43
  app.use((req, res, next) => {
package/http/router.js CHANGED
@@ -18,18 +18,20 @@ const { get_settings } = require('../setting');
18
18
  const init_router_dirs = (app, base_dir) => {
19
19
  const route_dirs = get_settings().server.routes;
20
20
 
21
- route_dirs.forEach(route_dir => {
22
- const full_route_dir = path.join(base_dir, route_dir);
23
- const routes = fs.readdirSync(full_route_dir);
24
- routes.forEach(route => {
25
- const router = require(`${base_dir}/${route_dir}/${route}`);
26
- const basename = path.basename(route, '.js');
27
- app.use('/' + basename, router);
21
+ if (route_dirs) {
22
+ route_dirs.forEach(route_dir => {
23
+ const full_route_dir = path.join(base_dir, route_dir);
24
+ const routes = fs.readdirSync(full_route_dir);
25
+ routes.forEach(route => {
26
+ const router = require(`${base_dir}/${route_dir}/${route}`);
27
+ const basename = path.basename(route, '.js');
28
+ app.use('/' + basename, router);
29
+ });
28
30
  });
29
- });
30
31
 
31
- //after init all the router, then validate all the meta informations
32
- validate_all_metas();
32
+ //after init all the router, then validate all the meta informations
33
+ validate_all_metas();
34
+ }
33
35
  }
34
36
 
35
37
  /**
package/http/session.js CHANGED
@@ -6,7 +6,7 @@ const init_session = (app) => {
6
6
  const server = get_settings().server;
7
7
  const mongo = get_settings().mongo;
8
8
 
9
- if (server.keep_session) {
9
+ if (server.keep_session && mongo) {
10
10
  const session = server.session;
11
11
 
12
12
  app.use(express_session({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hola-server",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "a meta programming framework used to build nodejs restful api",
5
5
  "main": "index.js",
6
6
  "scripts": {