soul-cli 0.0.2 → 0.0.4

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/.env.sample CHANGED
@@ -4,7 +4,7 @@ NODE_ENV=development
4
4
 
5
5
  CORS_ORIGIN_WHITELIST=http://localhost:3000,http://127.0.0.1:3000
6
6
 
7
- RATE_LIMIT_ENABLED=True
7
+ RATE_LIMIT_ENABLED=False
8
8
  RATE_LIMIT_WINDOW_MS=1000
9
9
  RATE_LIMIT_MAX_REQUESTS=10
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soul-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "A SQLite RESTful server",
5
5
  "main": "src/server.js",
6
6
  "bin": {
@@ -4,6 +4,8 @@ const path = require('path');
4
4
 
5
5
  const { yargs, usage, options } = require('../cli');
6
6
 
7
+ const { argv } = yargs;
8
+
7
9
  dotenv.config({ path: path.join(__dirname, '../../.env') });
8
10
 
9
11
  const envVarsSchema = Joi.object()
@@ -12,29 +14,47 @@ const envVarsSchema = Joi.object()
12
14
 
13
15
  NODE_ENV: Joi.string()
14
16
  .valid('production', 'development', 'test')
15
- .required(),
17
+ .default('production'),
16
18
 
17
19
  DB: Joi.string().required(),
18
20
  VERBOSE: Joi.string().valid('console', null).default(null),
19
21
 
20
- CORS_ORIGIN_WHITELIST: Joi.string().required(),
22
+ CORS_ORIGIN_WHITELIST: Joi.string().default('*'),
21
23
 
22
- RATE_LIMIT_ENABLED: Joi.boolean().required(),
23
- RATE_LIMIT_WINDOW_MS: Joi.number().positive().required(),
24
- RATE_LIMIT_MAX_REQUESTS: Joi.number().positive().required(),
24
+ RATE_LIMIT_ENABLED: Joi.boolean().default(false),
25
+ RATE_LIMIT_WINDOW_MS: Joi.number().positive().default(1000),
26
+ RATE_LIMIT_MAX_REQUESTS: Joi.number().positive().default(10),
25
27
  })
26
28
  .unknown();
27
29
 
30
+ const env = {
31
+ ...process.env,
32
+ };
33
+
34
+ if (argv.port) {
35
+ env.PORT = argv.port;
36
+ }
37
+
38
+ if (argv.verbose) {
39
+ env.VERBOSE = argv.verbose;
40
+ }
41
+
42
+ if (argv.db) {
43
+ env.DB = argv.database;
44
+ }
45
+
46
+ if (argv['rate-limit-enabled']) {
47
+ env.RATE_LIMIT_ENABLED = argv['rate-limit-enabled'];
48
+ }
49
+
28
50
  const { value: envVars, error } = envVarsSchema
29
51
  .prefs({ errors: { label: 'key' } })
30
- .validate(process.env);
52
+ .validate(env);
31
53
 
32
54
  if (error) {
33
55
  throw new Error(`Config validation error: ${error.message}`);
34
56
  }
35
57
 
36
- const { argv } = yargs;
37
-
38
58
  module.exports = {
39
59
  env: envVars.NODE_ENV,
40
60
 
package/src/server.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  const app = require('./index');
2
4
  const config = require('./config/index');
3
5