-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.ts
113 lines (105 loc) · 2.34 KB
/
config.ts
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
import * as firebase from 'firebase-admin'
import fs from 'fs'
export interface SonolusOptions {
/**
* Sonolus-client-version (Strict)
*/
version: string,
/**
* Specifies sonolus-express endpoint.
* Ex. If specify /api, you access with http://localhost:3000/api
*/
basePath: string,
/**
* Default locale of sonolus content
*/
fallbackLocale: string
}
export interface GlobalConfig {
/**
* Running port of server
*/
port: number,
/**
* User uploaded files will stored to here
*/
uploads: string,
/**
* Static files (sonolus-server-landing and others) will stored to here
*/
static: string,
/**
* Packed files (sonolus-pack) will stored to here
*/
packer: string,
/**
* Base engine of level
*/
engine: string,
/**
* Max file size of upload
*/
maxSize: number,
/**
* ProjectId of google cloud logging
*/
projectId: string,
/**
* Options of sonolus-express
*/
sonolusOptions: SonolusOptions,
}
export interface ServiceAccount {
type: string;
project_id: string;
private_key_id: string;
private_key: string;
client_email: string;
client_id: string;
auth_uri: string;
token_uri: string;
auth_provider_x509_cert_url: string;
client_x509_cert_url: string;
}
/**
* Global configuration of sonolus-uploader-core2
*/
let conf: GlobalConfig = {
port: 3000,
uploads: './uploads',
static: './public',
packer: './db/pack',
engine: 'pjsekai',
maxSize: 15 * 1024 * 1024,
projectId: '',
sonolusOptions: {
version: '0.5.5',
basePath: '',
fallbackLocale: 'ja'
}
}
try {
const rawConfig = fs.readFileSync('./config/settings.json', 'utf8')
conf = JSON.parse(rawConfig) as GlobalConfig
} catch {
console.log('Failed to load settings.json, using default conf.')
}
export const config : GlobalConfig = conf
/**
* Service account for firebase authorization
*/
const fireConf: firebase.ServiceAccount = {
clientEmail: '',
privateKey: '',
projectId: ''
}
try {
const rawSA = fs.readFileSync('./config/serviceAccount.json', 'utf8')
const sa = JSON.parse(rawSA) as ServiceAccount
fireConf.clientEmail = sa.client_email
fireConf.privateKey = sa.private_key
fireConf.projectId = sa.project_id
} catch {
console.log('Failed to load serviceAccount.json, using default conf.')
}
export const firebaseParams: firebase.ServiceAccount = fireConf