miolo 3.0.0-beta.13 → 3.0.0-beta.131

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 (52) hide show
  1. package/bin/{dev.mjs → dev/dev.mjs} +19 -5
  2. package/bin/{dev_start.mjs → dev/dev_start.mjs} +3 -2
  3. package/bin/index.mjs +47 -33
  4. package/bin/prod-bin/create-bin.mjs +33 -0
  5. package/bin/prod-bin/run.mjs +35 -0
  6. package/bin/{build-client.mjs → prod-build/build-client.mjs} +17 -5
  7. package/bin/{build-server.mjs → prod-build/build-server.mjs} +12 -10
  8. package/bin/prod-run/pid.mjs +13 -0
  9. package/bin/{restart.mjs → prod-run/restart.mjs} +3 -4
  10. package/bin/prod-run/start.mjs +14 -0
  11. package/bin/{stop.mjs → prod-run/stop.mjs} +4 -3
  12. package/bin/util.mjs +2 -29
  13. package/package.json +25 -26
  14. package/{bin → src/config}/.env +17 -6
  15. package/src/config/defaults.mjs +443 -422
  16. package/src/config/env.mjs +52 -0
  17. package/src/config/index.mjs +17 -10
  18. package/src/config/util.mjs +41 -0
  19. package/src/engines/emailer/queue.mjs +3 -2
  20. package/src/engines/emailer/transporter.mjs +10 -9
  21. package/src/engines/http/index.mjs +1 -1
  22. package/src/engines/parser/Parser.mjs +25 -7
  23. package/src/engines/schema/index.mjs +40 -0
  24. package/src/index.mjs +3 -1
  25. package/src/middleware/auth/basic.mjs +5 -2
  26. package/src/middleware/auth/credentials/index.mjs +75 -43
  27. package/src/middleware/auth/credentials/session/index.mjs +7 -0
  28. package/src/middleware/auth/credentials/session/store.mjs +9 -0
  29. package/src/middleware/context/index.mjs +1 -1
  30. package/src/middleware/http/catcher.mjs +78 -2
  31. package/src/middleware/http/catcher.old.mjs +82 -0
  32. package/src/middleware/http/custom_blacklist.mjs +3 -1
  33. package/src/middleware/routes/catch_js_error.mjs +14 -2
  34. package/src/middleware/routes/router/crud/attachCrudRoutes.mjs +24 -12
  35. package/src/middleware/routes/router/crud/getCrudConfig.mjs +4 -6
  36. package/src/middleware/routes/router/defaults.mjs +1 -11
  37. package/src/middleware/routes/router/index.mjs +0 -1
  38. package/src/middleware/routes/router/queries/attachQueriesRoutes.mjs +70 -13
  39. package/src/middleware/routes/router/queries/getQueriesConfig.mjs +21 -21
  40. package/src/middleware/routes/router/utils.mjs +43 -25
  41. package/src/middleware/ssr/context.mjs +1 -1
  42. package/src/middleware/ssr/fallbackIndex.mjs +2 -8
  43. package/src/middleware/ssr/html.mjs +39 -31
  44. package/src/middleware/vite/devserver.mjs +22 -8
  45. package/src/server-cron.mjs +3 -4
  46. package/src/server-dev.mjs +3 -3
  47. package/src/server.mjs +3 -5
  48. package/bin/create-bin.mjs +0 -38
  49. package/bin/env.mjs +0 -39
  50. package/bin/prod_start.mjs +0 -9
  51. package/bin/start.mjs +0 -17
  52. package/src/engines/logger/verify.mjs +0 -22
@@ -9,465 +9,486 @@ const SESSION_MAX_AGE = 86400 * 10 * 1000
9
9
  // Then you can configure miolo using process.env.WHATEVER.
10
10
 
11
11
 
12
- export default {
13
- name: process.env.MIOLO_NAME || 'miolo',
14
- http: {
15
- port: process.env?.MIOLO_PORT || 8001,
16
- hostname: process.env?.IS_DOCKER === "true"
17
- ? '0.0.0.0'
18
- : process.env?.MIOLO_HOSTNAME || 'localhost',
12
+ export default function make_config_defaults() {
13
+
14
+ return {
15
+ name: process.env.MIOLO_NAME || 'miolo',
16
+ http: {
17
+ port: process.env?.MIOLO_PORT || 8001,
18
+ hostname: process.env?.IS_DOCKER === "true"
19
+ ? (process.env?.MIOLO_HOSTNAME_DOCKER || '0.0.0.0')
20
+ : (process.env?.MIOLO_HOSTNAME || 'localhost'),
19
21
 
20
- catcher_url: '/sys/jserror',
21
-
22
- static: {
23
- favicon: '',
24
- folders: {}
25
- },
26
-
27
- // cors can be:
28
- // - false
29
- // - simple (just assign Access-Control-Allow-Origin='*' and Access-Control-Expose-Headers='SourceMap,X-SourceMap'
30
- // - true enable @koa/cors
31
- // - {options} enable @koa/cors and use the custom options
32
- //
33
- cors: process.env.MIOLO_HTTP_CORS==='true'
34
- ? true
35
- : process.env.MIOLO_HTTP_CORS==='simple'
36
- ? 'simple'
37
- : false,
22
+ catcher_url: '/sys/jserror',
23
+
24
+ static: {
25
+ favicon: '',
26
+ folders: {}
27
+ },
28
+
29
+ // cors can be:
30
+ // - false
31
+ // - simple (just assign Access-Control-Allow-Origin='*' and Access-Control-Expose-Headers='SourceMap,X-SourceMap'
32
+ // - true enable @koa/cors
33
+ // - {options} enable @koa/cors and use the custom options
34
+ //
35
+ cors: process.env.MIOLO_HTTP_CORS==='true'
36
+ ? true
37
+ : process.env.MIOLO_HTTP_CORS==='simple'
38
+ ? 'simple'
39
+ : false,
38
40
 
39
- // proxy can be:
40
- // - false
41
- // - true enable koa-proxies and use default options
42
- // - {options} enable koa-proxies and use the custom options
43
- proxy: process.env.MIOLO_HTTP_PROXY==='true',
41
+ // proxy can be:
42
+ // - false
43
+ // - true enable koa-proxies and use default options
44
+ // - {options} enable koa-proxies and use the custom options
45
+ proxy: process.env.MIOLO_HTTP_PROXY==='true',
44
46
 
45
- ratelimit: {
46
- /* eslint-disable no-unused-vars */
47
- max: parseInt(process.env.MIOLO_RATELIMIT_MAX || 1000),
48
- duration: parseInt(process.env.MIOLO_RATELIMIT_DURATION || 60 * 1000), // miliseconds
49
- errorMessage: 'Rate Limit reached',
50
- //whitelist: (ctx) => false,
51
- //blacklist: (ctx) => false,
52
- whitelist_ips: process.env.MIOLO_RATELIMIT_WHITELIST_IPS?.split(',') || [],
53
- blacklist_ips: process.env.MIOLO_RATELIMIT_BLACKLIST_IPS?.split(',') || [],
54
- ipsum_folder: '/var/ipsum' // https://github.com/stamparm/ipsum
55
- },
47
+ ratelimit: {
48
+ max: parseInt(process.env.MIOLO_RATELIMIT_MAX || 1000),
49
+ duration: parseInt(process.env.MIOLO_RATELIMIT_DURATION || 60 * 1000), // miliseconds
50
+ errorMessage: 'Rate Limit reached',
51
+ //whitelist: (ctx) => false,
52
+ //blacklist: (ctx) => false,
53
+ whitelist_ips: process.env.MIOLO_RATELIMIT_WHITELIST_IPS?.split(',') || [],
54
+ blacklist_ips: process.env.MIOLO_RATELIMIT_BLACKLIST_IPS?.split(',') || [],
55
+ ipsum_folder: '/var/ipsum' // https://github.com/stamparm/ipsum
56
+ },
56
57
 
57
- request: {
58
- lazy: parseInt(process.env.MIOLO_REQUEST_LAZY || 1), // seconds to consider lazy a request
59
- slow: parseInt(process.env.MIOLO_REQUEST_SLOW || 2), // seconds to consider slow a request
60
- onStart: undefined,
61
- // (ctx, times) => { return begin_result}
62
- onDone: undefined,
63
- // (ctx, begin_result, times) => {},
64
- geoip: {
65
- enabled: process.env.MIOLO_GEOIP_ENABLED==='true',
66
- db: process.env.MIOLO_GEOIP_DB,
67
- local_ips: process.env.MIOLO_GEOIP_LOCAL_IPS?.split(',') || [
68
- '127.0.0.1'
69
- ]
58
+ request: {
59
+ lazy: parseInt(process.env.MIOLO_REQUEST_LAZY || 1), // seconds to consider lazy a request
60
+ slow: parseInt(process.env.MIOLO_REQUEST_SLOW || 2), // seconds to consider slow a request
61
+ onStart: undefined,
62
+ // (ctx, times) => { return begin_result}
63
+ onDone: undefined,
64
+ // (ctx, begin_result, times) => {},
65
+ geoip: {
66
+ enabled: process.env.MIOLO_GEOIP_ENABLED==='true',
67
+ db: process.env.MIOLO_GEOIP_DB,
68
+ local_ips: process.env.MIOLO_GEOIP_LOCAL_IPS?.split(',') || [
69
+ '127.0.0.1'
70
+ ]
71
+ }
70
72
  }
71
- }
72
-
73
- },
74
- session: {
75
- salt: process.env.MIOLO_SESSION_SALT || 'SUPER_SALTY_YES?',
76
- secret: process.env.MIOLO_SESSION_SECRET || 'SUPER_SECRET_KEY_KERE',
77
- options: {
78
- /** (number || 'session') maxAge in ms (default is 1 days) */
79
- /** 'session' will result in a cookie that expires when session/browser is closed */
80
- /** Warning: If a session cookie is stolen, this cookie will never expire */
81
- maxAge: parseInt(process.env.MIOLO_SESSION_MAX_AGE || SESSION_MAX_AGE),
82
-
83
- /** (boolean) automatically commit headers (default true) */
84
- //autoCommit: true,
85
-
86
- /** (boolean) can overwrite or not (default true) */
87
- //overwrite: true,
88
-
89
- /** (boolean) httpOnly or not (default true) */
90
- //httpOnly: true,
91
-
92
- /** (boolean) signed or not (default true) */
93
- //signed: true,
94
-
95
- /** (boolean) Force a session identifier cookie to be set on every response. The expiration is reset to the original maxAge, resetting the expiration countdown. (default is false) */
96
- //rolling: false,
97
73
 
98
- /** (boolean) renew session when session is nearly expired, so we can always keep user logged in. (default is false)*/
99
- //renew: false,
74
+ },
75
+ session: {
76
+ salt: process.env.MIOLO_SESSION_SALT || 'SUPER_SALTY_YES?',
77
+ secret: process.env.MIOLO_SESSION_SECRET || 'SUPER_SECRET_KEY_KERE',
78
+ options: {
79
+ /** (string) cookie key (default is koa.sess) */
80
+ key: process.env.MIOLO_SESSION_KEY || `${process.env.MIOLO_NAME || 'koa'}.sess`,
81
+ /** (number || 'session') maxAge in ms (default is 1 days) */
82
+ /** 'session' will result in a cookie that expires when session/browser is closed */
83
+ /** Warning: If a session cookie is stolen, this cookie will never expire */
84
+ maxAge: parseInt(process.env.MIOLO_SESSION_MAX_AGE || SESSION_MAX_AGE),
85
+
86
+ /** (boolean) automatically commit headers (default true) */
87
+ //autoCommit: true,
88
+
89
+ /** (boolean) can overwrite or not (default true) */
90
+ //overwrite: true,
91
+
92
+ /** (boolean) httpOnly or not (default true) */
93
+ //httpOnly: true,
94
+
95
+ /** (boolean) signed or not (default true) */
96
+ //signed: true,
97
+
98
+ /** (boolean) Force a session identifier cookie to be set on every response. The expiration is reset to the original maxAge, resetting the expiration countdown. (default is false) */
99
+ //rolling: false,
100
+
101
+ /** (boolean) renew session when session is nearly expired, so we can always keep user logged in. (default is false)*/
102
+ renew: process.env?.MIOLO_SESSION_RENEW === 'true',
100
103
 
101
- /** (boolean) secure cookie*/
102
- /** You may want to set it as true in your Production environement,
103
- * while false at DEV time.
104
- */
105
- secure: process.env?.MIOLO_SESSION_SECURE === 'true',
106
-
107
- /** (string) session cookie sameSite options (default null, don't set it) */
108
- sameSite: 'lax', // 'strict',
109
- }
110
- },
111
- db: {
112
- config: {
113
- dialect: process.env.MIOLO_DB_DIALECT || 'postgres',
114
- host: process.env.MIOLO_DB_HOST || 'localhost',
115
- port: process.env.MIOLO_DB_PORT || 5432,
116
- database: process.env.MIOLO_DB_DATABASE || 'miolo',
117
- user: process.env.MIOLO_DB_USER || 'postgres',
118
- password: process.env.MIOLO_DB_PASSWORD || 'postgres',
119
- // Maximum number of connection in pool
120
- max: parseInt(process.env.MIOLO_DB_POOL_MAX || 5),
121
- // Minimum number of connection in pool
122
- min: parseInt(process.env.MIOLO_DB_POOL_MIN || 0),
123
- // The maximum time, in milliseconds, that a connection can be idle before being released.
124
- // Use with combination of evict for proper working,
125
- // for more details read https://github.com/coopernurse/node-pool/issues/178#issuecomment-327110870,
126
- idleTimeoutMillis: parseInt(process.env.MIOLO_DB_POOL_IDLE_TIMEOUT_MS || 10000),
104
+ /** (boolean) secure cookie*/
105
+ /** You may want to set it as true in your Production environement,
106
+ * while false at DEV time.
107
+ */
108
+ secure: process.env?.MIOLO_SESSION_SECURE === 'true',
109
+
110
+ /** (string) session cookie sameSite options (default null, don't set it) */
111
+ sameSite: process.env.MIOLO_SESSION_SAME_SITE || 'lax', // 'strict',
112
+ }
127
113
  },
128
- options: {
129
- tables: []
114
+ db: {
115
+ config: {
116
+ dialect: process.env.MIOLO_DB_DIALECT || 'postgres',
117
+ host: process.env?.IS_DOCKER === "true"
118
+ ? (process.env.MIOLO_DB_DOCKER_HOST || 'postgres')
119
+ : (process.env.MIOLO_DB_HOST || 'localhost'),
120
+ port: process.env.MIOLO_DB_PORT || 5432,
121
+ database: process.env.MIOLO_DB_DATABASE || 'miolo',
122
+ user: process.env.MIOLO_DB_USER || 'postgres',
123
+ password: process.env.MIOLO_DB_PASSWORD || 'postgres',
124
+ // Maximum number of connection in pool
125
+ max: parseInt(process.env.MIOLO_DB_POOL_MAX || 5),
126
+ // Minimum number of connection in pool
127
+ min: parseInt(process.env.MIOLO_DB_POOL_MIN || 0),
128
+ // The maximum time, in milliseconds, that a connection can be idle before being released.
129
+ // Use with combination of evict for proper working,
130
+ // for more details read https://github.com/coopernurse/node-pool/issues/178#issuecomment-327110870,
131
+ idleTimeoutMillis: parseInt(process.env.MIOLO_DB_POOL_IDLE_TIMEOUT_MS || 10000),
132
+ },
133
+ options: {
134
+ tables: []
130
135
 
131
- // cache:
132
- // Refer to top level cache option
133
- // cache: {...}
134
-
135
- // log:
136
- // We will pass, on the fly, miolo logger to calustra
137
- // But specifying a level here, we can customize the level only for db/calustra actions
138
- // log: 'silly',
139
- }
140
- },
141
- routes: {
142
- bodyField: undefined,
143
-
144
- // auth: {
145
- // require: false, // true / false / 'read-only'
146
- // action: 'redirect', // 'error'
147
- // redirect_url: '/',
148
- // error_code: 401
149
- // },
150
- // before: async (ctx) => {return bool} // If bool false, query callback not run
151
- // after : async (ctx, result) => {return modified_result}
136
+ // cache:
137
+ // Refer to top level cache option
138
+ // cache: {...}
139
+
140
+ // log:
141
+ // We will pass, on the fly, miolo logger to calustra
142
+ // But specifying a level here, we can customize the level only for db/calustra actions
143
+ // log: 'silly',
144
+ }
145
+ },
146
+ routes: {
147
+ bodyField: undefined,
152
148
 
153
- crud: [{
154
- prefix: '',
155
- routes: [/*
156
- name: '',
157
- url: '/../..', // default to 'name'
158
- mode: 'r/w/rw',
159
- bodyField: '',
149
+ // auth: {
150
+ // require: false, // true / false / 'read-only'
151
+ // action: 'redirect', // 'error'
152
+ // redirect_url: '/',
153
+ // error_code: 401
154
+ // },
155
+ // before: async (ctx) => {return bool} // If bool false, query callback not run
156
+ // after : async (ctx, data) => {return modified_data}
157
+
158
+ crud: [{
159
+ prefix: '',
160
+ routes: [/*
161
+ name: '',
162
+ url: '/../..', // default to 'name'
163
+ mode: 'r/w/rw',
164
+ bodyField: '',
160
165
 
161
- useUserFields: {
162
- use: false,
163
- fieldNames: {
164
- created_by: 'created_by',
165
- last_update_by: 'last_update_by'
166
+ useUserFields: {
167
+ use: false,
168
+ fieldNames: {
169
+ created_by: 'created_by',
170
+ last_update_by: 'last_update_by'
171
+ }
166
172
  }
167
- }
168
- auth: ...,
169
- before: ...,
170
- after : ...
171
- */],
172
- }],
173
- queries: [/*
174
- {
175
- prefix: '',
176
- auth: ...,
177
- before: ...,
178
- after : ...
173
+ auth: ...,
174
+ before: ...,
175
+ after : ...
176
+ */],
177
+ }],
178
+ queries: [/*
179
+ {
180
+ prefix: '',
181
+ auth: ...,
182
+ before: ...,
183
+ after : ...
179
184
 
180
- routes: [
181
- {
182
- url: '/../..',
183
- method: 'GET/POST',
184
- callback: async (ctx) => { ctx.body = result } ,
185
- // or
186
- callback_fn: async (miolo, params) => { return result } ,
187
- auth: ...,
188
- before: ...,
189
- after : ...
190
- },
191
- ],
192
- },
193
- */],
194
- },
195
- log: {
196
- level: process.env.MIOLO_LOG_LEVEL || 'debug',
197
- format: {
198
- locale: 'en-GB'
199
- },
200
- console: {
201
- enabled: process.env.MIOLO_LOG_CONSOLE_ENABLED === 'true',
202
- level: process.env.MIOLO_LOG_CONSOLE_LEVEL || process.env.MIOLO_LOG_LEVEL || 'debug',
185
+ routes: [
186
+ {
187
+ url: '/../..',
188
+ method: 'GET/POST',
189
+ callback: async (ctx, params) => {
190
+ return {ok: true/false, data|error}
191
+ // or:
192
+ // return <anything>
193
+ // and milo will wrap into {ok: true, data: <anything>}
194
+ // or by yourself:
195
+ // ctx.body = {ok: true/false, data|error}
196
+ // (you may want {keep_body: true})
197
+ } ,
198
+ auth: ...,
199
+ before: async (ctx) => { return true/false },
200
+ after : async (ctx, data) => { return data },
201
+ schema: a Joi schema,
202
+ keep_body: false by default. If true, miolo wont wnsure ctx.body after callback.
203
+ },
204
+ ],
205
+ },
206
+ */],
203
207
  },
204
- file: {
205
- enabled: process.env.MIOLO_LOG_FILE_ENABLED === 'true',
206
- level: process.env.MIOLO_LOG_FILE_LEVEL || process.env.MIOLO_LOG_LEVEL || 'debug',
207
- filename: process.env.MIOLO_LOG_FILE_PATH || '/var/log/afialapis/%MIOLO%.log',
208
-
209
- //frequency: undefined,
210
- //datePattern: 'YYYY-MM-DD',
211
- zippedArchive: true,
208
+ log: {
209
+ level: process.env.MIOLO_LOG_LEVEL || 'debug',
210
+ format: {
211
+ locale: 'en-GB'
212
+ },
213
+ console: {
214
+ enabled: process.env.MIOLO_LOG_CONSOLE_ENABLED === 'true',
215
+ level: process.env.MIOLO_LOG_CONSOLE_LEVEL || process.env.MIOLO_LOG_LEVEL || 'debug',
216
+ },
217
+ file: {
218
+ enabled: process.env.MIOLO_LOG_FILE_ENABLED === 'true',
219
+ level: process.env.MIOLO_LOG_FILE_LEVEL || process.env.MIOLO_LOG_LEVEL || 'debug',
220
+ filename: process.env.MIOLO_LOG_FILE_PATH || '/var/log/afialapis/%MIOLO%.log',
221
+
222
+ //frequency: undefined,
223
+ //datePattern: 'YYYY-MM-DD',
224
+ zippedArchive: true,
212
225
 
213
- maxsize: 1024 * 1024 * 20,
214
- maxFiles: 20,
226
+ maxsize: 1024 * 1024 * 20,
227
+ maxFiles: 20,
215
228
 
216
- //maxSize: '20m',
217
- ///maxFiles: '10d',
229
+ //maxSize: '20m',
230
+ ///maxFiles: '10d',
218
231
 
219
- //filename: '/var/log/afialapis/%MIOLO%.%DATE%.log',
220
- //auditFile: '/var/log/afialapis/%MIOLO%.audit.json',
221
- //createSymlink: true,
222
- //symlinkName: '%MIOLO%.log'
232
+ //filename: '/var/log/afialapis/%MIOLO%.%DATE%.log',
233
+ //auditFile: '/var/log/afialapis/%MIOLO%.audit.json',
234
+ //createSymlink: true,
235
+ //symlinkName: '%MIOLO%.log'
223
236
 
224
- hup_patch: false
237
+ hup_patch: false
238
+ },
239
+ mail: {
240
+ enabled: process.env.MIOLO_LOG_MAIL_ENABLED
241
+ ? process.env.MIOLO_LOG_MAIL_ENABLED === 'true'
242
+ : false,
243
+ level: process.env.MIOLO_LOG_MAIL_LEVEL || process.env.MIOLO_LOG_LEVEL || 'warn',
244
+ name: process.env.MIOLO_NAME || 'miolo',
245
+ from: process.env.MIOLO_LOG_MAIL_FROM || 'noreply@mail.com',
246
+ to: process.env.MIOLO_LOG_MAIL_TO || 'noreply@mail.com'
247
+ }
225
248
  },
226
249
  mail: {
227
- enabled: process.env.MIOLO_LOG_MAIL_ENABLED
228
- ? process.env.MIOLO_LOG_MAIL_ENABLED === 'true'
229
- : false,
230
- level: process.env.MIOLO_LOG_MAIL_LEVEL || process.env.MIOLO_LOG_LEVEL || 'warn',
231
- name: process.env.MIOLO_NAME || 'miolo',
232
- from: process.env.MIOLO_LOG_MAIL_FROM || 'noreply@mail.com',
233
- to: process.env.MIOLO_LOG_MAIL_TO || 'noreply@mail.com'
234
- }
235
- },
236
- mail: {
237
- silent: process.env.MIOLO_MAILER_SILENT === 'true',
238
- options: {
239
- //
240
- // General options
241
- //
242
- // portis the port to connect to (defaults to 587 is secure is false or 465 if true)
243
- port: parseInt(process.env.MIOLO_MAILER_PORT || 25),
244
- // host is the hostname or IP address to connect to (defaults to ‘localhost’)
245
- host: process.env.MIOLO_MAILER_HOST || 'mail.com',
246
- // auth – defines authentication data
247
- // If authentication data is not present, the connection is considered authenticated from the start.
248
- // Otherwise you would need to provide the authentication options object.
249
- // - type indicates the authetication type, defaults to ‘login’, other option is ‘oauth2’
250
- // - user is the username
251
- // - pass is the password for the user if normal login is used
252
- // authMethod – defines preferred authentication method, defaults to ‘PLAIN’
253
- authMethod: process.env.MIOLO_MAILER_AUTH_METHOD || 'PLAIN',
254
- ... process.env.MIOLO_MAILER_AUTH_METHOD === 'LOGIN'
255
- ? {
256
- auth: {
257
- user: process.env.MIOLO_MAILER_SMTP_USER || 'noreply@mail.com',
258
- pass: process.env.MIOLO_MAILER_SMTP_PASS || '****',
259
- type: 'login',
250
+ silent: process.env.MIOLO_MAILER_SILENT === 'true',
251
+ options: {
252
+ //
253
+ // General options
254
+ //
255
+ // port is the port to connect to (defaults to 587 is secure is false or 465 if true)
256
+ port: parseInt(process.env.MIOLO_MAILER_PORT || 25),
257
+ // host – is the hostname or IP address to connect to (defaults to ‘localhost’)
258
+ host: process.env.MIOLO_MAILER_HOST || 'mail.com',
259
+ // auth – defines authentication data
260
+ // If authentication data is not present, the connection is considered authenticated from the start.
261
+ // Otherwise you would need to provide the authentication options object.
262
+ // - type indicates the authetication type, defaults to ‘login’, other option is ‘oauth2’
263
+ // - user is the username
264
+ // - pass is the password for the user if normal login is used
265
+ // authMethoddefines preferred authentication method, defaults to ‘PLAIN’
266
+ authMethod: process.env.MIOLO_MAILER_AUTH_METHOD || 'PLAIN',
267
+ ... process.env.MIOLO_MAILER_AUTH_METHOD === 'LOGIN'
268
+ ? {
269
+ auth: {
270
+ user: process.env.MIOLO_MAILER_SMTP_USER || 'noreply@mail.com',
271
+ pass: process.env.MIOLO_MAILER_SMTP_PASS || '****',
272
+ type: 'login',
273
+ },
274
+ secure: true,
275
+ }
276
+ : {
277
+ secure: false
260
278
  },
261
- secure: true,
262
- }
263
- : {
264
- secure: false
265
- },
266
279
 
267
- //
268
- // TLS options
269
- //
270
- // secure – if true the connection will use TLS when connecting to server.
271
- // If false (the default) then TLS is used if server supports the STARTTLS extension.
272
- // In most cases set this value to true if you are connecting to port 465. For port 587 or 25 keep it false
273
- // ** Setting secure to false does not mean that you would not use an encrypted connection. Most SMTP servers allow
274
- // connection upgrade via STARTTLS command but to use this you have to connect using plaintext first
275
-
280
+ //
281
+ // TLS options
282
+ //
283
+ // secure – if true the connection will use TLS when connecting to server.
284
+ // If false (the default) then TLS is used if server supports the STARTTLS extension.
285
+ // In most cases set this value to true if you are connecting to port 465. For port 587 or 25 keep it false
286
+ // ** Setting secure to false does not mean that you would not use an encrypted connection. Most SMTP servers allow
287
+ // connection upgrade via STARTTLS command but to use this you have to connect using plaintext first
276
288
 
277
- // tls – defines additional node.js TLSSocket options to be passed to the socket constructor, eg. {rejectUnauthorized: true}.
278
- tls: {
279
- // do not fail on invalid certs
280
- rejectUnauthorized: false
281
- } ,
282
- // ignoreTLS – if this is true and secure is false then TLS is not used even if the server supports STARTTLS extension
283
- // ** ignoreTLS: false,
284
- // requireTLS if this is true and secure is false then Nodemailer tries to use STARTTLS even
285
- // if the server does not advertise support for it. If the connection can not be encrypted then message is not sent
286
- // ** requireTLS: true,
287
- //
288
- // Connection options
289
- //
290
- // name – optional hostname of the client, used for identifying to the server, defaults to hostname of the machine
291
- // ** name: ,
292
- // localAddress is the local interface to bind to for network connections
293
- // ** localAddress: ,
294
- // connectionTimeout how many milliseconds to wait for the connection to establish
295
- // ** connectionTimeout: ,
296
- // greetingTimeout how many milliseconds to wait for the greeting after connection is established
297
- // ** greetingTimeout: ,
298
- // socketTimeout how many milliseconds of inactivity to allow
299
- // ** socketTimeout: ,
300
- //
301
- // Debug options
302
- //
303
- // logger – optional bunyan compatible logger instance. If set to true then logs to console.
304
- // If value is not set or is false then nothing is logged
305
- logger: false,
306
- // debug – if set to true, then logs SMTP traffic, otherwise logs only transaction events
307
- debug: false,
308
- //
309
- // Security options
310
- //
311
- // disableFileAccess – if true, then does not allow to use files as content.
312
- // Use it when you want to use JSON data from untrusted source as the email.
313
- // If an attachment or message node tries to fetch something from a file the sending returns an error
314
- ////disableFileAccess: ,
315
- // disableUrlAccess – if true, then does not allow to use Urls as content
316
- // ** disableUrlAccess: ,
289
+
290
+ // tls – defines additional node.js TLSSocket options to be passed to the socket constructor, eg. {rejectUnauthorized: true}.
291
+ tls: {
292
+ // do not fail on invalid certs
293
+ rejectUnauthorized: false
294
+ } ,
295
+ // ignoreTLS – if this is true and secure is false then TLS is not used even if the server supports STARTTLS extension
296
+ // ** ignoreTLS: false,
297
+ // requireTLS if this is true and secure is false then Nodemailer tries to use STARTTLS even
298
+ // if the server does not advertise support for it. If the connection can not be encrypted then message is not sent
299
+ // ** requireTLS: true,
300
+ //
301
+ // Connection options
302
+ //
303
+ // name – optional hostname of the client, used for identifying to the server, defaults to hostname of the machine
304
+ // ** name: ,
305
+ // localAddress – is the local interface to bind to for network connections
306
+ // ** localAddress: ,
307
+ // connectionTimeout – how many milliseconds to wait for the connection to establish
308
+ // ** connectionTimeout: ,
309
+ // greetingTimeout – how many milliseconds to wait for the greeting after connection is established
310
+ // ** greetingTimeout: ,
311
+ // socketTimeout – how many milliseconds of inactivity to allow
312
+ // ** socketTimeout: ,
313
+ //
314
+ // Debug options
315
+ //
316
+ // logger optional bunyan compatible logger instance. If set to true then logs to console.
317
+ // If value is not set or is false then nothing is logged
318
+ logger: false,
319
+ // debug – if set to true, then logs SMTP traffic, otherwise logs only transaction events
320
+ debug: false,
321
+ //
322
+ // Security options
323
+ //
324
+ // disableFileAccess if true, then does not allow to use files as content.
325
+ // Use it when you want to use JSON data from untrusted source as the email.
326
+ // If an attachment or message node tries to fetch something from a file the sending returns an error
327
+ ////disableFileAccess: ,
328
+ // disableUrlAccess – if true, then does not allow to use Urls as content
329
+ // ** disableUrlAccess: ,
317
330
 
318
- //
319
- // Pooling options
320
- //
321
- // pool – see Pooled SMTP for details about connection pooling : https://nodemailer.com/smtp/pooled/
322
- //
323
- // Proxy options
324
- //
325
- // proxy – all SMTP based transports allow to use proxies for making TCP connections to servers.
326
- // Read about proxy support in Nodemailer from here: https://nodemailer.com/smtp/proxies/
327
- },
328
- defaults: {
329
- name: process.env.MIOLO_NAME || 'miolo',
330
- from: process.env.MIOLO_MAILER_FROM || 'noreply@mail.com',
331
- to: process.env.MIOLO_MAILER_TO || 'noreply@mail.com'
332
- }
333
- },
334
- auth: {
335
- //basic: {
336
- // auth_user: async (username, password) => { return {id: 1} },
337
- // realm: '',
338
- // paths: [],
339
- //},
340
- //credentials: {
341
- // get_user_id: (user, done, miolo) => done(null, user.id), // default
342
- // find_user_by_id: (id, done, miolo) => done(null, {id: 1}), // ok=> done(null, user) err=> done(error, null)
343
- // local_auth_user: (username, password, done, miolo) => done(null, {id: 1})
344
- // // auth=> done(null, user) noauth=> done(null, false, {message: ''}) err=> done(error, null)
345
- // url_login : '/login',
346
- // url_logout: '/logout',
347
- // url_login_redirect: undefined
348
- // url_logout_redirect: '/'
349
- //}
350
- //guest: {
351
- // make_guest_token: undefined // (session) => ''
352
- //},
353
- //custom: callback,
354
- // here callback receives (app)
355
- // and returns:
356
- // - a middleware function
357
- // or
358
- // - an array like [{
359
- // method: 'GET' // POST,...
360
- // url: '/aa/bb',
361
- // callback: a middleware function
362
- // }, ...]
363
- },
364
-
365
- middlewares: [
366
- // async (ctx, next) => {}
367
- // Remember to call `await next()`
368
- ],
369
- cron: [
370
- // {
371
- // name,
372
- // cronTime,
373
- // onTick: async (miolo, onComplete),
374
- // Notice that if task runs too fast, you may see that
375
- // onTick is actually never run, but onComplete is.
376
- // Consider passing a higher interval on cronTime
377
- // onComplete: async (miolo),
378
- // timezone, context, runOnInit, utcOffset, unrefTimeout
379
- // }
380
- // check https://github.com/kelektiv/node-cron#readme
381
- //
382
- // https://crontab.guru/
383
- ],
384
-
385
- cache: {
386
- // Default options passed to cacheiro for
387
- // every other cache
388
- default: {
389
- type: 'combined',
390
- redis: {
391
- host: '127.0.0.1',
392
- port: 6379
331
+ //
332
+ // Pooling options
333
+ //
334
+ // pool – see Pooled SMTP for details about connection pooling : https://nodemailer.com/smtp/pooled/
335
+ //
336
+ // Proxy options
337
+ //
338
+ // proxy – all SMTP based transports allow to use proxies for making TCP connections to servers.
339
+ // Read about proxy support in Nodemailer from here: https://nodemailer.com/smtp/proxies/
393
340
  },
394
- version: parseInt(process.env.MIOLO_CACHE_VERSION || 1),
395
- clean: false,
341
+ defaults: {
342
+ name: process.env.MIOLO_NAME || 'miolo',
343
+ from: process.env.MIOLO_MAILER_FROM || 'noreply@mail.com',
344
+ to: process.env.MIOLO_MAILER_TO || 'noreply@mail.com'
345
+ }
396
346
  },
397
-
398
- // specific cache options for calustra
399
- calustra: {
400
- namespace: 'miolo-calustra',
401
- ttl: parseInt(process.env.MIOLO_CACHE_CALUSTRA_TTL || 86400*1000),
402
- version: parseInt(process.env.MIOLO_CACHE_CALUSTRA_VERSION || process.env.MIOLO_CACHE_VERSION || 1)
347
+ auth: {
348
+ //basic: {
349
+ // auth_user: async (username, password) => { return {id: 1} },
350
+ // realm: '',
351
+ // paths: [],
352
+ //},
353
+ //credentials: {
354
+ // get_user_id: (user, done, ctx) => done(null, user.id), // default
355
+ // find_user_by_id: (id, done, ctx) => done(null, {id: 1}), // ok=> done(null, user) err=> done(error, null)
356
+ // local_auth_user: (username, password, done, ctx) => done(null, {id: 1})
357
+ // auth => done(null, user)
358
+ // noauth=> done(null, false, {message: ''})
359
+ // err => done(error, null)
360
+ // url_login : '/login',
361
+ // url_logout: '/logout',
362
+ // url_login_redirect: undefined
363
+ // url_logout_redirect: '/'
364
+ //}
365
+ //guest: {
366
+ // make_guest_token: undefined // (session) => ''
367
+ //},
368
+ //custom: callback,
369
+ // here callback receives (app)
370
+ // and returns:
371
+ // - a middleware function
372
+ // or
373
+ // - an array like [{
374
+ // method: 'GET' // POST,...
375
+ // url: '/aa/bb',
376
+ // callback: a middleware function
377
+ // }, ...]
403
378
  },
404
379
 
405
- // specific cache options for koa-session
406
- session: {
407
- namespace: 'miolo-session',
408
- ttl: parseInt(process.env.MIOLO_CACHE_SESSION_TTL || process.env.MIOLO_SESSION_MAX_AGE || SESSION_MAX_AGE),
409
- version: parseInt(process.env.MIOLO_CACHE_SESSION_VERSION || process.env.MIOLO_CACHE_VERSION || 1)
410
- },
411
-
412
- // custom cache instances
413
- // will be inited by miolo, and available through ctx.miolo.cache.get_cache('name')
414
- custom: {
415
- // <name>: {options}
416
- }
380
+ middlewares: [
381
+ // async (ctx, next) => {}
382
+ // Remember to call `await next()`
383
+ ],
384
+ cron: [
385
+ // {
386
+ // name,
387
+ // cronTime,
388
+ // onTick: async (miolo, onComplete),
389
+ // Notice that if task runs too fast, you may see that
390
+ // onTick is actually never run, but onComplete is.
391
+ // Consider passing a higher interval on cronTime
392
+ // onComplete: async (miolo),
393
+ // timezone, context, runOnInit, utcOffset, unrefTimeout
394
+ // }
395
+ // check https://github.com/kelektiv/node-cron#readme
396
+ //
397
+ // https://crontab.guru/
398
+ ],
417
399
 
400
+ cache: {
401
+ // Default options passed to cacheiro for
402
+ // every other cache
403
+ default: {
404
+ type: process.env.MIOLO_CACHE_TYPE || 'combined',
405
+ redis: {
406
+ host: process.env?.IS_DOCKER === "true"
407
+ ? (process.env.MIOLO_REDIS_HOSTNAME_DOCKER || 'redis')
408
+ : (process.env.MIOLO_REDIS_HOSTNAME || '127.0.0.1'),
409
+ port: parseInt(process.env.MIOLO_REDIS_PORT || 6379)
410
+ },
411
+ version: parseInt(process.env.MIOLO_CACHE_VERSION || 1),
412
+ clean: false,
413
+ },
414
+
415
+ // specific cache options for calustra
416
+ calustra: {
417
+ namespace: 'miolo-calustra',
418
+ ttl: parseInt(process.env.MIOLO_CACHE_CALUSTRA_TTL || 86400*1000),
419
+ version: parseInt(process.env.MIOLO_CACHE_CALUSTRA_VERSION || process.env.MIOLO_CACHE_VERSION || 1)
420
+ },
418
421
 
419
- },
422
+ // specific cache options for koa-session
423
+ session: {
424
+ namespace: 'miolo-session',
425
+ ttl: parseInt(process.env.MIOLO_CACHE_SESSION_TTL || process.env.MIOLO_SESSION_MAX_AGE || SESSION_MAX_AGE),
426
+ version: parseInt(process.env.MIOLO_CACHE_SESSION_VERSION || process.env.MIOLO_CACHE_VERSION || 1)
427
+ },
428
+
429
+ // custom cache instances
430
+ // will be inited by miolo, and available through ctx.miolo.cache.get_cache('name')
431
+ custom: {
432
+ // <name>: {options}
433
+ }
420
434
 
421
- socket: {
422
- enabled: false,
423
- cli: {
424
- /**
425
- domain: '',
426
- options: {}
427
- */
428
- }
429
- /*
430
- connection: (socket) => {},
431
- new_namespace: (namespace) => {},
432
- namespaces: [{
433
- name,
434
- listener: (data) => {}
435
- }]
436
- */
437
- },
438
435
 
439
- build: {
440
-
441
- client: process.env.NODE_ENV === 'production'
442
- ? `${process.env.MIOLO_BUILD_CLIENT_DEST}/${process.env.MIOLO_NAME}.${process.env.MIOLO_BUNDLE_SUFFIX}.js`
443
- : process.env.MIOLO_BUILD_CLIENT_ENTRY,
444
-
445
- html: process.env.MIOLO_BUILD_HTML_FILE || './src/cli/index.html',
436
+ },
446
437
 
447
- vite: {
448
- base: '/',
449
- root: '',
450
- watch: {
451
- // During tests we edit the files too fast and sometimes chokidar
452
- // misses change events, so enforce polling for consistency
453
- usePolling: true,
454
- interval: 100,
455
- },
438
+ socket: {
439
+ enabled: false,
440
+ cli: {
441
+ /**
442
+ domain: '',
443
+ options: {}
444
+ */
445
+ }
446
+ /*
447
+ connection: (socket) => {},
448
+ new_namespace: (namespace) => {},
449
+ namespaces: [{
450
+ name,
451
+ listener: (data) => {}
452
+ }]
453
+ */
456
454
  },
455
+
456
+ build: {
457
457
 
458
- ssr: {
459
- server: process.env.NODE_ENV === 'production'
460
- ? path.join(process.cwd(), `${process.env.MIOLO_BUILD_SERVER_DEST}/entry-server.js`)
461
- : process.env.MIOLO_BUILD_SERVER_SSR_ENTRY
462
- // loader: async (ctx) => {}
463
- },
458
+ client: process.env.NODE_ENV === 'production'
459
+ ? `${process.env.MIOLO_BUILD_CLIENT_DEST || './dist/cli'}/${process.env.MIOLO_NAME || 'miolo'}.${process.env.MIOLO_BUILD_CLIENT_SUFFIX || 'iife.bundle.min'}.js`
460
+ : process.env.MIOLO_BUILD_CLIENT_ENTRY,
461
+
462
+ html: process.env.MIOLO_BUILD_HTML_FILE==='false'
463
+ ? ''
464
+ : process.env.MIOLO_BUILD_HTML_FILE || './src/cli/index.html',
464
465
 
465
- dev: {
466
- watcher: {
467
- enabled: process.env.MIOLO_DEV_WATCH_ENABLED==='true',
468
- dirs: process.env.MIOLO_DEV_WATCH_DIRS?.split(',')?.map(dir => path.join(process.cwd(), dir)) || [],
466
+ vite: {
467
+ base: '/',
468
+ root: '',
469
+ watch: {
470
+ // During tests we edit the files too fast and sometimes chokidar
471
+ // misses change events, so enforce polling for consistency
472
+ usePolling: true,
473
+ interval: 100,
474
+ },
469
475
  },
476
+
477
+ ssr: {
478
+ server: process.env.NODE_ENV === 'production'
479
+ ? path.join(process.cwd(), `${process.env.MIOLO_BUILD_SERVER_DEST || './dist/server'}/entry-server.js`)
480
+ : process.env.MIOLO_BUILD_SERVER_SSR_ENTRY || './src/server/ssr/entry-server.jsx',
481
+ // loader: async (ctx) => {}
482
+ },
483
+
484
+ dev: {
485
+ watcher: {
486
+ enabled: process.env.MIOLO_DEV_WATCH_ENABLED==='true',
487
+ dirs: process.env.MIOLO_DEV_WATCH_DIRS?.split(',')?.map(dir => path.join(process.cwd(), dir)) || [],
488
+ },
489
+ }
470
490
  }
471
491
  }
472
- };
492
+ }
493
+
473
494