style(api): apply prettier formatting
This commit is contained in:
1 parent
80fef25af3
commit
96fede9fe5
75 files changed
+955
-674
No files matched your search
@@ -9,7 +9,8 @@ import { DakaoOutboxService } from './dakao-outbox.service';
|
||||
|
||||
const SWEEP_INTERVAL_MS = 60 * 1000;
|
||||
const STALE_OUTBOX_MS = 5 * 60 * 1000;
|
||||
const SWEEP_LOCK_KEY = 'distributed-lock:dakao-outbox:sweep-stale-publish-leases';
|
||||
const SWEEP_LOCK_KEY =
|
||||
'distributed-lock:dakao-outbox:sweep-stale-publish-leases';
|
||||
const SWEEP_LOCK_EXPIRATION_DURATION_MILLISECONDS = 55_000;
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -78,35 +78,29 @@ export class DakaoOutboxService {
|
||||
await this.natsService.publishJetStream(params.subject, params.envelope, {
|
||||
messageId: params.eventId,
|
||||
});
|
||||
await OutboxModel.updateOne(
|
||||
updateFilter,
|
||||
{
|
||||
$set: {
|
||||
state: 'published',
|
||||
publishedAt: new Date(),
|
||||
},
|
||||
$inc: { publishAttempts: 1 },
|
||||
$unset: {
|
||||
lastPublishError: '',
|
||||
publishLeaseOwnerIdentifier: '',
|
||||
publishLeaseExpiresAt: '',
|
||||
},
|
||||
await OutboxModel.updateOne(updateFilter, {
|
||||
$set: {
|
||||
state: 'published',
|
||||
publishedAt: new Date(),
|
||||
},
|
||||
).exec();
|
||||
$inc: { publishAttempts: 1 },
|
||||
$unset: {
|
||||
lastPublishError: '',
|
||||
publishLeaseOwnerIdentifier: '',
|
||||
publishLeaseExpiresAt: '',
|
||||
},
|
||||
}).exec();
|
||||
} catch (err) {
|
||||
await OutboxModel.updateOne(
|
||||
updateFilter,
|
||||
{
|
||||
$inc: { publishAttempts: 1 },
|
||||
$set: {
|
||||
lastPublishError: (err as Error)?.message ?? String(err),
|
||||
},
|
||||
$unset: {
|
||||
publishLeaseOwnerIdentifier: '',
|
||||
publishLeaseExpiresAt: '',
|
||||
},
|
||||
await OutboxModel.updateOne(updateFilter, {
|
||||
$inc: { publishAttempts: 1 },
|
||||
$set: {
|
||||
lastPublishError: (err as Error)?.message ?? String(err),
|
||||
},
|
||||
).exec();
|
||||
$unset: {
|
||||
publishLeaseOwnerIdentifier: '',
|
||||
publishLeaseExpiresAt: '',
|
||||
},
|
||||
}).exec();
|
||||
this.logger.error(
|
||||
`Failed to publish Dakao outbox eventId=${params.eventId}: ${
|
||||
(err as Error)?.stack ?? err
|
||||
|
||||
@@ -104,9 +104,11 @@ describe('MatchCancelHandler', () => {
|
||||
const handler = makeHandler({
|
||||
matchService: {
|
||||
cancelJoin,
|
||||
list: jest.fn().mockResolvedValue([
|
||||
{ _id: matchId, title: '저녁 내전', shortCode: 'AB12' },
|
||||
]),
|
||||
list: jest
|
||||
.fn()
|
||||
.mockResolvedValue([
|
||||
{ _id: matchId, title: '저녁 내전', shortCode: 'AB12' },
|
||||
]),
|
||||
} as Partial<MatchService>,
|
||||
dakaoUserService: {
|
||||
findUserByKakaoTalkId,
|
||||
|
||||
@@ -230,9 +230,11 @@ describe('MatchJoinHandler', () => {
|
||||
const resolveRiotAccount = jest.fn();
|
||||
const handler = makeHandler({
|
||||
matchService: {
|
||||
list: jest.fn().mockResolvedValue([
|
||||
{ _id: matchId, title: '저녁 내전', shortCode: 'AB12' },
|
||||
]),
|
||||
list: jest
|
||||
.fn()
|
||||
.mockResolvedValue([
|
||||
{ _id: matchId, title: '저녁 내전', shortCode: 'AB12' },
|
||||
]),
|
||||
join,
|
||||
} as Partial<MatchService>,
|
||||
dakaoUserService: {
|
||||
@@ -282,9 +284,11 @@ describe('MatchJoinHandler', () => {
|
||||
const join = jest.fn();
|
||||
const handler = makeHandler({
|
||||
matchService: {
|
||||
list: jest.fn().mockResolvedValue([
|
||||
{ _id: matchId, title: '저녁 내전', shortCode: 'AB12' },
|
||||
]),
|
||||
list: jest
|
||||
.fn()
|
||||
.mockResolvedValue([
|
||||
{ _id: matchId, title: '저녁 내전', shortCode: 'AB12' },
|
||||
]),
|
||||
join,
|
||||
} as Partial<MatchService>,
|
||||
dakaoUserService: {
|
||||
|
||||
@@ -44,9 +44,7 @@ export class MatchJoinHandler {
|
||||
return this.errorReply(params, joinTarget);
|
||||
}
|
||||
|
||||
let resolved:
|
||||
| { user: UserDocument; riotAccount: RiotAccount }
|
||||
| string;
|
||||
let resolved: { user: UserDocument; riotAccount: RiotAccount } | string;
|
||||
try {
|
||||
resolved =
|
||||
joinTarget.gameName && joinTarget.tagLine
|
||||
@@ -243,10 +241,7 @@ export class MatchJoinHandler {
|
||||
const gameName = normalizeRiotIdPart(value.slice(splitAt + 1));
|
||||
if (!matchTitlePrefix || !gameName) continue;
|
||||
|
||||
const result = resolveRecruitingMatchReference(
|
||||
matchTitlePrefix,
|
||||
matches,
|
||||
);
|
||||
const result = resolveRecruitingMatchReference(matchTitlePrefix, matches);
|
||||
if (result.kind === 'matched') {
|
||||
return { kind: 'matched', match: result.match, gameName };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user