File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { env } from '~/config/env'
2+
3+ /**
4+ * Check if storage is enabled
5+ */
6+ export function storageExists ( ) : boolean {
7+ switch ( env . STORAGE_PROVIDER ) {
8+ case 'minio' :
9+ return Boolean (
10+ env . STORAGE_HOST &&
11+ env . STORAGE_BUCKET_NAME &&
12+ env . STORAGE_ACCESS_KEY &&
13+ env . STORAGE_SECRET_KEY
14+ )
15+
16+ case 's3' :
17+ return Boolean ( env . STORAGE_BUCKET_NAME && env . STORAGE_ACCESS_KEY && env . STORAGE_SECRET_KEY )
18+
19+ case 'gcs' :
20+ return Boolean ( env . STORAGE_ACCESS_KEY && env . STORAGE_BUCKET_NAME && env . STORAGE_FILEPATH )
21+
22+ default :
23+ return false
24+ }
25+ }
Original file line number Diff line number Diff line change 11import http from 'http'
2+ import { initDatabase } from './app/database/connection'
23import { App } from './config/app'
34import { env } from './config/env'
5+ import { storage } from './config/storage'
6+ import { storageExists } from './lib/boolean'
47import { httpHandle } from './lib/http/handle'
5- import { initDatabase } from './app/database/connection'
68
79function bootstrap ( ) {
810 const port = env . APP_PORT
911 const app = new App ( ) . create
1012 const server = http . createServer ( app )
13+ const isStorageEnabled = storageExists ( )
1114
15+ // initial database
1216 initDatabase ( )
1317
18+ // initial storage
19+ if ( isStorageEnabled ) {
20+ storage . initialize ( )
21+ }
22+
1423 // http handle
1524 const { onError, onListening } = httpHandle ( server , port )
1625
You can’t perform that action at this time.
0 commit comments