UNPKG

@nu-art/bug-report

Version:
51 lines (50 loc) 2.34 kB
"use strict"; /* * Permissions management system, define access level for each of * your server apis, and restrict users by giving them access levels * * Copyright (C) 2020 Adam van der Kruk aka TacB0sS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ModuleBE_AdminBR = exports.ModuleBE_AdminBR_Class = void 0; const ts_common_1 = require("@nu-art/ts-common"); const api_1 = require("../../shared/api"); const backend_1 = require("@nu-art/firebase/backend"); const backend_2 = require("@nu-art/thunderstorm/backend"); class ModuleBE_AdminBR_Class extends ts_common_1.Module { constructor() { super(); this.getFilesFirebase = async () => this.bugReport.getAll(); this.downloadFiles = async (path) => { var _a; const bucket = await this.storage.getOrCreateBucket((_a = this.config) === null || _a === void 0 ? void 0 : _a.bucket); const file = await bucket.getFile(path.path); return file.getReadSignedUrl(600000, 'application/zip'); }; } init() { super.init(); const sessAdmin = backend_1.ModuleBE_Firebase.createAdminSession(); const firestore = sessAdmin.getFirestore(); this.bugReport = firestore.getCollection('bug-report', ['_id']); this.storage = sessAdmin.getStorage(); (0, backend_2.addRoutes)([ (0, backend_2.createBodyServerApi)(api_1.ApiDef_AdminBugReport.v1.downloadLogs, exports.ModuleBE_AdminBR.downloadFiles), (0, backend_2.createQueryServerApi)(api_1.ApiDef_AdminBugReport.v1.retrieveLogs, exports.ModuleBE_AdminBR.getFilesFirebase), ]); } } exports.ModuleBE_AdminBR_Class = ModuleBE_AdminBR_Class; exports.ModuleBE_AdminBR = new ModuleBE_AdminBR_Class();