diff --git a/packages/be-gateway/src/core/AppRoutes.ts b/packages/be-gateway/src/core/AppRoutes.ts index eda217f6..16babbc3 100644 --- a/packages/be-gateway/src/core/AppRoutes.ts +++ b/packages/be-gateway/src/core/AppRoutes.ts @@ -127,7 +127,7 @@ export const AppRoutes = (routeControllers: any[]) => { } } catch (error) { console.log('AppRoute2', error) - res.status(500).send(error) + res.status(500).send(JSON.stringify(error)) } }) } diff --git a/packages/be-gateway/src/routes/organization/index.controller.ts b/packages/be-gateway/src/routes/organization/index.controller.ts index 8f55466d..1d16257e 100644 --- a/packages/be-gateway/src/routes/organization/index.controller.ts +++ b/packages/be-gateway/src/routes/organization/index.controller.ts @@ -69,7 +69,8 @@ export class OrganizationController extends BaseController { @Post('') async createOrganization() { const req = this.req as AuthRequest - const res = this.res + const isProd = process.env.DEV_MODE === 'true' + try { const body = req.body as Pick const { id } = req.authen @@ -77,8 +78,8 @@ export class OrganizationController extends BaseController { const ownedOrgs = await mdOrgGetOwned(id) - if (ownedOrgs.length >= 1) { - return res.status(500).send('REACHED_MAX_ORGANIZATION') + if (isProd && ownedOrgs.length >= 1) { + throw new Error('REACHED_MAX_ORGANIZATION') } const result = await mdOrgAdd({ @@ -93,6 +94,8 @@ export class OrganizationController extends BaseController { updatedBy: null }) + console.log('created new organization') + delCache(key) await mdOrgMemAdd({ diff --git a/packages/be-gateway/src/routes/project/index.ts b/packages/be-gateway/src/routes/project/index.ts index 1da82d0e..31eecbbf 100644 --- a/packages/be-gateway/src/routes/project/index.ts +++ b/packages/be-gateway/src/routes/project/index.ts @@ -191,8 +191,9 @@ router.post('/project', async (req: AuthRequest, res) => { })) - console.log('create rest views but the first one') - await tx.projectView.createMany({ + console.log('create rest views but the first one', restViewDatas.length) + + restViewDatas.length && await tx.projectView.createMany({ data: restViewDatas }) diff --git a/packages/be-gateway/src/routes/storage/index.ts b/packages/be-gateway/src/routes/storage/index.ts index 674f5009..0a791dcb 100644 --- a/packages/be-gateway/src/routes/storage/index.ts +++ b/packages/be-gateway/src/routes/storage/index.ts @@ -59,7 +59,7 @@ router.post('/create-presigned-url', async (req, res, next) => { throw new MaxStorageSizeException() } - const { presignedUrl, randName } = await storageService.createPresignedUrl({ + const { presignedUrl, randName, url } = await storageService.createPresignedUrl({ projectId, name, type @@ -71,7 +71,7 @@ router.post('/create-presigned-url', async (req, res, next) => { data: { name: randName, presignedUrl, - url: getObjectURL(randName) + url: url } }) diff --git a/packages/be-gateway/src/services/storage.service.ts b/packages/be-gateway/src/services/storage.service.ts index f6738b4f..884ce670 100644 --- a/packages/be-gateway/src/services/storage.service.ts +++ b/packages/be-gateway/src/services/storage.service.ts @@ -28,6 +28,10 @@ export class StorageService { } + protected getObjectUrl() { + return '' + } + protected async initS3Client() { const awsConfig = await this.getStorageConfig() const s3Store = new AwsS3StorageProvider({ orgId: this.orgId, ...awsConfig }) @@ -93,7 +97,8 @@ export class StorageService { const presignedUrl = await s3Store.createPresignedUrlWithClient(randName, type) return { randName, - presignedUrl + presignedUrl, + url: s3Store.getObjectURL(randName) } } catch (error) { console.log(error)