Skip to content

Commit

Permalink
fix: blockchain timeout for create product
Browse files Browse the repository at this point in the history
  • Loading branch information
suk-6 committed Sep 24, 2024
1 parent b0f6103 commit 3646f4d
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/modules/product/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ProductService {
) {}

async createProduct(userId: string, dto: CreateProductDTO) {
return this.prisma.$transaction(
const product = await this.prisma.$transaction(
async (tx) => {
const product = await tx.product.create({
data: {
Expand Down Expand Up @@ -76,34 +76,37 @@ export class ProductService {
},
});

const address = await this.blockchain
.create(
dto.name,
product.id.split('-')[0],
`${this.configService.get('S3_PUBLIC_URL')}/${product.id}/1.png`,
)
.then((address) => {
console.log(address);
if (!address) throw new InternalServerErrorException('NFT 생성에 실패했습니다.');

return address;
});
return product;
},
{
timeout: 10000,
},
);

await tx.product.update({
this.blockchain
.create(
dto.name,
product.id.split('-')[0],
`${this.configService.get('S3_PUBLIC_URL')}/${product.id}/1.png`,
)
.then((address) => {
console.log(address);
if (!address) throw new InternalServerErrorException('NFT 생성에 실패했습니다.');

return address;
})
.then((address) =>
this.prisma.product.update({
where: {
id: product.id,
},
data: {
tokenAddress: address,
},
});
}),
);

return product;
},
{
timeout: 10000,
},
);
return product;
}

async updateProductType(userId: string, productId: string) {
Expand Down

0 comments on commit 3646f4d

Please sign in to comment.