-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnuxt.config.js
448 lines (405 loc) · 17 KB
/
nuxt.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
// Don't change this variable. If you want to enable/disable email, set the YB_EMAIL_HOST environment
// variable (and others, see below in privateRuntimeConfig for email settings)
const EMAIL_ENABLED = typeof process.env.YB_EMAIL_HOST === 'string' && process.env.YB_EMAIL_HOST.length > 0
const EMAIL_REQUIRED = EMAIL_ENABLED ? 'required|' : ''
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
publicRuntimeConfig: {
title: process.env.YB_TITLE || 'Yuebing 🥮',
// Links in outbound emails will point back here
siteUrl: process.env.YB_SITE_URL || 'http://127.0.0.1:3000',
// Set to true to allow anonymous browsing/viewing
// WARNING: This can generate expensive bandwidth bills, depending on your site's traffic load
public: process.env.YB_PUBLIC ? !!JSON.parse(process.env.YB_PUBLIC) : false,
// Set to true to allow people to sign up
allowRegistration: process.env.YB_ALLOW_REGISTRATION ? !!JSON.parse(process.env.YB_ALLOW_REGISTRATION) : false,
// If limitRegistration is set, the allowRegistration setting is ignored
// The limitRegistration property can be either:
// 1. A string representing a path on the destination bucket to a file containing a list of email
// addresses to allow registration from. The contents of this file can be a JSON array, or a flat
// text file with one email address per line
// 2. An array object, containing the email addresses to allow registration from
limitRegistration: process.env.YB_LIMIT_REGISTRATION || null,
// To add support for a new locale:
// - Add the locale name to the 'locales' array below
// - For UI/API strings: copy shared/messages/en.js to shared/messages/<locale>_messages.js and translate/adjust as needed
// - If email is enabled, copy the serverMiddleware/templates/email/en directory to a directory named after
// the new locale, then edit the files and translate/adjust as needed
locales: [
'ar', 'bn', 'de', 'en', 'es', 'fr', 'ha', 'hi', 'id', 'it', 'ja',
'ko', 'mr', 'pl', 'pt', 'ru', 'sw', 'tl', 'tr', 'ur', 'vi', 'zh'
],
defaultLocale: process.env.YB_DEFAULT_LOCALE || 'en',
// timeouts for various temporary tokens stored in redis
timeout: {
verify: process.env.YB_TIMEOUT_ACCOUNT_VERIFICATION || 1000 * 60 * 60 * 24 * 2, // 2 days
resetPassword: process.env.YB_TIMEOUT_RESET_PASSWORD || 1000 * 60 * 60, // 1 hour
// the various 'configurable' sections provide metadata (validation rules/etc) for
// the admin "manage config" screen
configurable: {
verify: {
rules: 'required|integer|min_value:0|max_value:3153600000000',
format: 'duration',
default: 1000 * 60 * 60 * 24 * 2 // 2 days
},
resetPassword: {
rules: 'required|integer|min_value:0|max_value:3153600000000',
format: 'duration',
default: 1000 * 60 * 60 // 1 hour
}
}
},
// When enabled, logged-in users will see an "invite friends" feature in page footer
inviteFriendsEnabled: process.env.YB_INVITE_FRIENDS_ENABLED || true,
// Don't change this line. If you want to enable/disable email, set the YB_EMAIL_HOST environment
// variable (and others, see below in privateRuntimeConfig for email settings)
emailEnabled: EMAIL_ENABLED,
// the various 'configurable' sections provide metadata (validation rules/etc) for the "System
// Configuration" page in the admin panel, which allows most settings to be updated at runtime
configurable: {
title: {
rules: 'required|min:2|max:500'
},
siteUrl: {
rules: 'required|url|min:2|max:1024'
},
public: {
rules: 'required',
format: 'flag',
default: false
},
allowRegistration: {
rules: 'required',
format: 'flag',
default: false
},
limitRegistration: {
rules: 'max:1024',
default: null
},
defaultLocale: {
rules: 'locale|min:2|max:5'
},
inviteFriendsEnabled: {
rules: 'required',
format: 'flag',
default: true
},
emailEnabled: {
rules: 'required',
format: 'flag',
default: EMAIL_ENABLED
}
}
},
privateRuntimeConfig: {
// Initial admin user, will be created if it does not exist
admin: {
user: {
email: process.env.YB_ADMIN_EMAIL || null,
username: process.env.YB_ADMIN_USERNAME || 'admin',
password: process.env.YB_ADMIN_PASSWORD || null,
locale: process.env.YB_ADMIN_LOCALE || process.env.YB_DEFAULT_LOCALE || 'en'
},
overwrite: !!process.env.YB_ADMIN_OVERWRITE // set to true to overwrite existing admin user
},
// SMTP settings for sending email
// If host is not set, emails will be disabled
// Do not set edit the lines below.
// Instead, set the YB_EMAIL environment variables to the config you want
email: {
host: process.env.YB_EMAIL_HOST || null,
port: process.env.YB_EMAIL_PORT || 587,
user: process.env.YB_EMAIL_USER || null,
password: process.env.YB_EMAIL_PASSWORD || null,
secure: process.env.YB_EMAIL_SECURE || true,
fromEmail: process.env.YB_EMAIL_FROM || '[email protected]',
configurable: {
host: {
rules: `${EMAIL_REQUIRED}host|min:6|max:128`
},
port: {
rules: `${EMAIL_REQUIRED}integer|min_value:10|max_value:65000`
},
user: {
rules: `${EMAIL_REQUIRED}min:2|max:100`
},
password: {
rules: `${EMAIL_REQUIRED}min:2|max:100`
},
secure: {
rules: EMAIL_REQUIRED,
format: 'flag'
},
fromEmail: {
rules: `${EMAIL_REQUIRED}email|min:2|max:100`
}
}
},
// redis is used for: server-side caching, the xform job queue, and web sessions
redis: {
host: process.env.YB_REDIS_HOST || '127.0.0.1',
port: process.env.YB_REDIS_PORT || 6379,
// Set to true to flush redis when the yuebing starts (this will log out all users)
// when false, any transform jobs abandoned from a previous run may cause show (benign) errors
// in your logs. Start another scan to reprocess the abandoned jobs.
flushAtStartup: (typeof process.env.YB_REDIS_FLUSH_AT_STARTUP !== 'undefined') ? !!JSON.parse(process.env.YB_REDIS_FLUSH_AT_STARTUP) : true,
// Set to true to build the search index when yuebing starts
// This could take a long time if you have a lot of media to index
// You can rebuild the index on-demand using the web admin
buildSearchIndexAtStartup: (typeof process.env.YB_BUILD_SEARCH_INDEX_AT_STARTUP !== 'undefined') ? !!JSON.parse(process.env.YB_BUILD_SEARCH_INDEX_AT_STARTUP) : false,
// Cache duration for manifests, in milliseconds
// Note that manifests will only be recalculated if the Last-Modified header of the `lastModified`
// file is newer than the cache's ctime
manifestCacheExpiration: process.env.YB_MANIFEST_CACHE_EXPIRATION || 60 * 1000, // default 1 minute
configurable: {
host: {
// eslint-disable-next-line no-useless-escape
rules: 'required|host|min:6|max:128'
},
port: {
rules: 'required|integer|min_value:10|max_value:65000'
},
flushAtStartup: {
rules: 'required',
format: 'flag',
default: true
},
listingCacheExpiration: {
rules: 'required|integer|min_value:0|max_value:3153600000000',
format: 'duration',
default: 5 * 60 * 1000 // default 5 minutes
},
manifestCacheExpiration: {
rules: 'required|integer|min_value:0|max_value:3153600000000',
format: 'duration',
default: 60 * 1000 // default 1 minute
}
}
},
// A map of supported (media type) -> (config for the media type)
//
// The existence of a mediaType named 'foo' implies that there exists:
// * A specification in 'shared/media/foo.js' to determine which files match and what to do with them
// * A page in 'pages/media/foo.vue' to display an individual media item with type foo
// * A driver in 'serverMiddleware/asset/driver/foo.js' that generates assets from a source of type foo
// - The driver must export a functions named after each operation that the driver supports
// See serverMiddleware/asset/driver/video.js for an example.
//
media: {
video: {
// 'allowedCommands' is a list of programs the driver is allowed to run.
//
// The first command listed is the default command and will be used for any profiles that
// do not specify a 'command' property.
//
// Anything that looks like a shell will fail validation (bash/zsh/ssh/etc)
allowedCommands: ['./scripts/ffmpeg_wrapper', './scripts/mediainfo_wrapper']
}
},
encryption: {
// Optional. Define these to encrypt data stored in destination bucket
//
// WARNING: if you change this, your data-storage location will be different, so
// existing users will no longer be able to sign in and nothing will really work.
// Login as admin and visit the /admin page to migrate to the new encryption key.
// You will need the old key/IV/algo combination to read the old data.
// Key rotation is expensive. We must read, decrypt, re-encrypt and re-write *everything* that is encrypted.
// It may take a long time. Also consider bandwidth costs between wherever this Nuxt server is running
// and wherever the storage is located.
key: process.env.YB_DATA_ENCRYPTION_KEY,
iv: process.env.YB_DATA_ENCRYPTION_IV, // IV is optional; if empty it is derived from key
algo: process.env.YB_DATA_ENCRYPTION_ALGO, // algo is optional; default is 'aes-256-cbc'
// Passwords are stored as bcrypt hashes. How many rounds to use
bcryptRounds: process.env.YB_BCRYPT_ROUNDS || 12,
configurable: {
key: {
rules: 'max:1024'
},
iv: {
rules: 'max:1024'
},
algo: {
rules: 'max:50'
},
bcryptRounds: {
rules: 'required|integer|min_value:8|max_value:100'
}
}
},
session: {
// How long web sessions last
expiration: process.env.YB_SESSION_EXPIRATION || 1000 * 60 * 60 * 24, // default 24 hours
configurable: {
expiration: {
rules: 'required|integer|min_value:0|max_value:3153600000000',
format: 'duration',
default: 1000 * 60 * 60 * 24
}
}
},
// The server scans the source media for new content to transform
autoscan: {
// When autoscan is disabled, you can still manually scan sources from the web admin console
enabled: process.env.YB_AUTOSCAN_ENABLED || false,
// How frequently to auto-scan the source for new content
// Otherwise, scan at this interval.
// Minimum interval is 1 minute. Lower settings are ignored.
// Only one scan runs at a time. If an active scan is already running when a new
// interval is triggered, a concurrent scan will NOT be started.
// If enabled, an initial scan will being shortly after startup
interval: process.env.YB_AUTOSCAN_INTERVAL || 1000 * 60 * 60 * 24, // default 24 hours
// How long to wait before the initial startup scan
// Minimum interval is 5 seconds. Lower settings are ignored.
initialDelay: process.env.YB_AUTOSCAN_INITIAL_DELAY || 1000 * 60 * 2, // default 2 minutes
// Show stdout/stderr from transform commands? It is a LOT of output (ffmpeg for example)
showTransformOutput: false,
// Delete temp files after transforming media.
// It can be useful to disable this when debugging problematic media transforms
cleanupTemporaryAssets: true,
// Delete incomplete uploads
// It can be useful to disable this when debugging problematic storage
deleteIncompleteUploads: true,
// How many concurrent transformations can be done
concurrency: process.env.YB_AUTOSCAN_XFORM_CONCURRENCY || 2,
configurable: {
enabled: {
rules: 'required',
format: 'flag',
default: true
},
interval: {
rules: 'integer|min_value:60000|max_value:3153600000000',
when: 'enabled',
format: 'duration',
default: 1000 * 60 * 60 * 24 // default 24 hours
},
initialDelay: {
rules: 'integer|min_value:60000|max_value:3153600000000',
when: 'enabled',
format: 'duration',
default: 1000 * 30 // default 30 seconds
},
showTransformOutput: {
rules: 'required',
format: 'flag',
default: false
},
cleanupTemporaryAssets: {
rules: 'required',
format: 'flag',
default: true
},
deleteIncompleteUploads: {
rules: 'required',
format: 'flag',
default: true
},
concurrency: {
rules: 'required|integer|min_value:1|max_value:10000',
default: 2
}
}
}
},
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: process.env.YB_TITLE || 'Yuebing 🥮',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' },
{ name: 'msapplication-TileColor', content: '#da532c' },
{ name: 'theme-color', content: '#ffffff' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: `${process.env.YB_FAVICON_DIR || ''}/favicon.ico` },
{ rel: 'apple-touch-icon', sizes: '180x180', href: `${process.env.YB_FAVICON_DIR || ''}/apple-touch-icon.png` },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: `${process.env.YB_FAVICON_DIR || ''}/favicon-32x32.png` },
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: `${process.env.YB_FAVICON_DIR || ''}/favicon-16x16.png` },
{ rel: 'manifest', href: `${process.env.YB_FAVICON_DIR || ''}/site.webmanifest` },
{ rel: 'mask-icon', href: `${process.env.YB_FAVICON_DIR || ''}/safari-pinned-tab.svg`, color: '#5bbad5' }
]
},
router: {
extendRoutes (routes, resolve) {
routes.push({
name: 'Sign In',
path: require(resolve(__dirname, 'shared/auth')).LOGIN_ENDPOINT,
component: resolve(__dirname, 'pages/auth/login.vue'),
chunkName: 'pages/auth/login'
})
routes.push({
name: 'Sign Up',
path: require(resolve(__dirname, 'shared/auth')).REGISTER_ENDPOINT,
component: resolve(__dirname, 'pages/auth/register.vue'),
chunkName: 'pages/auth/register'
})
routes.push({
name: 'Request Password Reset',
path: '/reset',
component: resolve(__dirname, 'pages/auth/requestPasswordReset.vue'),
chunkName: 'pages/auth/requestPasswordReset'
})
routes.push({
name: 'Verify',
path: require(resolve(__dirname, 'shared/auth')).VERIFY_ENDPOINT,
component: resolve(__dirname, 'pages/auth/verify.vue'),
chunkName: 'pages/auth/verify'
})
routes.push({
name: 'Account Profile',
path: '/profile',
component: resolve(__dirname, 'pages/auth/profile.vue'),
chunkName: 'pages/auth/profile'
})
}
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'vue-json-pretty/lib/styles.css'
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
'~/plugins/vee-validate.js',
'~/plugins/vuetify.js',
'~/plugins/vue-json-pretty.js'
],
// Don't load serverMiddleware here -- it's loaded via 'modules/api' below
// Loading the serverMiddleware during 'nuxt build' causes a nasty build warning message
// See: https://github.com/nuxt/nuxt.js/issues/5669#issuecomment-491241150
// serverMiddleware: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/eslint
'@nuxtjs/eslint-module',
'@nuxtjs/vuetify'
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
// this module loads the serverMiddleware when nuxt runs, but does not load it during 'nuxt build'
'~/modules/api'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
// Workaround to avoid enforcing hard-coded localhost:3000: https://github.com/nuxt-community/axios-module/issues/308
baseURL: '/'
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
mode: 'production',
transpile: ['vee-validate/dist/rules'],
extend (config) {
config.module.rules.push({
test: /^README.md$/i,
use: 'ignore-loader'
})
}
}
}