mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
support optional B2
service
This commit is contained in:
parent
7619c1f4d9
commit
0500118b68
@ -25,16 +25,23 @@ class API extends Server {
|
|||||||
cache: new CacheService(),
|
cache: new CacheService(),
|
||||||
redis: RedisClient(),
|
redis: RedisClient(),
|
||||||
storage: StorageClient(),
|
storage: StorageClient(),
|
||||||
b2Storage: new B2({
|
b2Storage: null,
|
||||||
applicationKeyId: process.env.B2_KEY_ID,
|
|
||||||
applicationKey: process.env.B2_APP_KEY,
|
|
||||||
}),
|
|
||||||
limits: {},
|
limits: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
async onInitialize() {
|
async onInitialize() {
|
||||||
global.storage = this.contexts.storage
|
global.storage = this.contexts.storage
|
||||||
global.b2Storage = this.contexts.b2Storage
|
|
||||||
|
if (process.env.B2_KEY_ID && process.env.B2_APP_KEY) {
|
||||||
|
this.contexts.b2Storage = new B2({
|
||||||
|
applicationKeyId: process.env.B2_KEY_ID,
|
||||||
|
applicationKey: process.env.B2_APP_KEY,
|
||||||
|
})
|
||||||
|
|
||||||
|
global.b2Storage = this.contexts.b2Storage
|
||||||
|
} else {
|
||||||
|
console.warn("B2 storage not configured on environment, skipping...")
|
||||||
|
}
|
||||||
|
|
||||||
await this.contexts.db.initialize()
|
await this.contexts.db.initialize()
|
||||||
await this.contexts.redis.initialize()
|
await this.contexts.redis.initialize()
|
||||||
|
@ -106,6 +106,10 @@ export default async ({
|
|||||||
|
|
||||||
switch (service) {
|
switch (service) {
|
||||||
case "b2":
|
case "b2":
|
||||||
|
if (!global.b2Storage) {
|
||||||
|
throw new OperationError(500, "B2 storage not configured on environment, unsupported service. Please use `standard` service.")
|
||||||
|
}
|
||||||
|
|
||||||
result = await b2Upload({
|
result = await b2Upload({
|
||||||
remotePath,
|
remotePath,
|
||||||
source,
|
source,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user