Skip to content

Commit

Permalink
[#137]feat: 배포
Browse files Browse the repository at this point in the history
  • Loading branch information
Arios67 committed Apr 5, 2022
1 parent e0148c8 commit 6cb0e69
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 20 deletions.
1 change: 1 addition & 0 deletions ars/src/apis/art/art.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class ArtResolver {
start_price: el._source.start_price,
instant_bid: el._source.instant_bid,
deadline: el._source.deadline,
is_soldout: el._source.is_soldout,
thumbnail: el._source.thumbnail,
tag1: el._source.tag1,
tag2: el._source.tag2,
Expand Down
7 changes: 4 additions & 3 deletions ars/src/apis/art/art.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export class ArtService {
.where('user.id =:id', { id: currentUser.id })
.withDeleted()
.getMany();

return art;
}

Expand Down Expand Up @@ -175,6 +176,7 @@ export class ArtService {
}
}
///////////////////////////////////////////////////////////////////////////

async countEngage(userId) {
const queryRunner = this.connection.createQueryRunner();
await queryRunner.connect();
Expand All @@ -187,7 +189,6 @@ export class ArtService {
return result;
} catch (error) {
await queryRunner.rollbackTransaction();
throw error + 'Art create !';
} finally {
await queryRunner.manager.release();
}
Expand All @@ -205,7 +206,6 @@ export class ArtService {
return result;
} catch (error) {
await queryRunner.rollbackTransaction();
throw error + 'Art create !';
} finally {
await queryRunner.manager.release();
}
Expand All @@ -219,7 +219,7 @@ export class ArtService {
.where('user.id =:id', { id: userId })
.withDeleted()
.getCount();

return art;
}

Expand All @@ -237,5 +237,6 @@ export class ArtService {
});
return result;
}

///////////////////////////////////////////////////////////////////////////
}
2 changes: 1 addition & 1 deletion ars/src/apis/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AuthService {
{ email: user.email, sub: user.id },
{ secret: process.env.REFRESH_TOKEN_KEY, expiresIn: '8h' },
);
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000');
res.setHeader('Access-Control-Allow-Origin', 'https://artipul.shop');
res.setHeader(
'Set-Cookie',
`refreshToken=${refreshToken}; path=/; domain=.daseul.shop; SameSite=None; Secure;httpOnly;`,
Expand Down
4 changes: 2 additions & 2 deletions ars/src/apis/board/board.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class BoardResolver {

// 게시물 모두 조회
@Query(() => [Board])
async fetchBoards(@Args('page', { nullable: true }) page: number) {
return await this.boardService.findAll(page);
async fetchBoards() {
return await this.boardService.findAll();
}

// 내가 쓴 게시물 조회
Expand Down
35 changes: 25 additions & 10 deletions ars/src/apis/board/board.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ export class BoardService {

// 게시물 1개 조회
async findOne(boardId: string) {
return await this.boardRepository.findOne(boardId);
return await this.boardRepository.findOne({
where: { id: boardId },
relations: ['art'],
withDeleted: true,
});
}

// 게시물 이미지 조회
async findImage({ boardId }) {
return await this.boardImageRepository.find({ board: boardId });
return await this.boardImageRepository.find({
where: { board: boardId },
relations: ['board'],
});
}

// 게시물 모두 조회
async findAll(page) {
async findAll() {
return await this.boardRepository.find({
relations: ['art'],
take: 10,
skip: 10 * (page - 1),
});
}

Expand Down Expand Up @@ -65,9 +70,11 @@ export class BoardService {
const user = await queryRunner.manager.findOne(User, {
id: currentUser.id,
});
const art = await queryRunner.manager.findOne(Art, {
id: artId,
});
const art = await getRepository(Art)
.createQueryBuilder('art')
.where('art.id = :id', { id: artId })
.withDeleted()
.getOne();

const result = await queryRunner.manager.save(Board, {
...rest,
Expand Down Expand Up @@ -106,18 +113,26 @@ export class BoardService {
await queryRunner.connect();
await queryRunner.startTransaction();
try {
const board = await queryRunner.manager.findOne(Board, { id: boardId });
const board = await this.boardRepository.findOne({
where: { id: boardId },
relations: ['art'],
withDeleted: true,
});
const user = await queryRunner.manager.findOne(User, {
id: currentUser.id,
});

const result = await queryRunner.manager.save(Board, {
...board,
...rest,
user: user,
thumbnail: image_urls[0],
});

for (let i = 0; i < image_urls.lenght; i++) {
await queryRunner.manager.delete(BoardImage, {
board: result,
});
for (let i = 0; i < image_urls.length; i++) {
if (i === 0) {
await queryRunner.manager.save(BoardImage, {
url: image_urls[i],
Expand Down
2 changes: 1 addition & 1 deletion ars/src/apis/event/event.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Server, Socket } from 'socket.io';

@WebSocketGateway({
cors: {
origin: ['http://localhost:3000', 'https://daseul.shop'],
origin: ['https://daseul.shop', 'https://artipul.shop'],
},
namespace: /./,
})
Expand Down
2 changes: 1 addition & 1 deletion ars/src/apis/payment/payment.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class PaymentResolver {
const bidder = await this.userService.findOne(currentUser.email);
await this.paymentService.successfulBid(artId, price, bidder, artist);

const result = await this.elasticsearchService.deleteByQuery({
await this.elasticsearchService.deleteByQuery({
index: 'artipul00',
query: {
bool: {
Expand Down
2 changes: 1 addition & 1 deletion ars/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { EventModule } from './apis/event/event.module';
driver: ApolloDriver,
autoSchemaFile: 'src/common/graphql/schema.gql',
context: ({ req, res }) => ({ req, res }),
cors: { origin: 'http://localhost:3000', credential: true },
cors: { origin: 'https://artipul.shop', credential: true },
}),
TypeOrmModule.forRoot({
type: 'mysql',
Expand Down
2 changes: 1 addition & 1 deletion ars/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NestExpressApplication } from '@nestjs/platform-express';
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.enableCors({
origin: 'http://localhost:3000',
origin: 'https://artipul.shop',
credentials: true,
});
app.use(graphqlUploadExpress());
Expand Down

0 comments on commit 6cb0e69

Please sign in to comment.