Skip to content

Commit

Permalink
fix: hardcode image url (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
hudy9x authored Mar 2, 2024
1 parent 77c0282 commit ad147b4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/be-gateway/src/core/AppRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,17 @@ 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<Organization, 'name' | 'desc' | 'cover'>
const { id } = req.authen
const key = [CKEY.USER_ORGS, id]

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({
Expand All @@ -93,6 +94,8 @@ export class OrganizationController extends BaseController {
updatedBy: null
})

console.log('created new organization')

delCache(key)

await mdOrgMemAdd({
Expand Down
5 changes: 3 additions & 2 deletions packages/be-gateway/src/routes/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
4 changes: 2 additions & 2 deletions packages/be-gateway/src/routes/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -71,7 +71,7 @@ router.post('/create-presigned-url', async (req, res, next) => {
data: {
name: randName,
presignedUrl,
url: getObjectURL(randName)
url: url
}
})

Expand Down
7 changes: 6 additions & 1 deletion packages/be-gateway/src/services/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ad147b4

Please sign in to comment.