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