Skip to content

Commit 494e0f4

Browse files
committed
chore: lint
Signed-off-by: Innei <tukon479@gmail.com>
1 parent ec77c38 commit 494e0f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+146
-173
lines changed

apps/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@
162162
"vite-tsconfig-paths": "5.1.4",
163163
"vitest": "1.5.2"
164164
}
165-
}
165+
}

apps/core/src/app.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { Auth } from '~/common/decorators/auth.decorator'
1010
import { InjectModel } from '~/transformers/model.transformer'
1111
import dayjs from 'dayjs'
1212
import PKG from '../package.json'
13-
import { DEMO_MODE } from './app.config'
1413
import { HttpCache } from './common/decorators/cache.decorator'
1514
import { HTTPDecorators } from './common/decorators/http.decorator'
1615
import { IpLocation, IpRecord } from './common/decorators/ip.decorator'

apps/core/src/common/interceptors/idempotence.interceptor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export class IdempotenceInterceptor implements NestInterceptor {
101101
const resultValue: '0' | '1' | null = (await redis.get(
102102
idempotenceKey,
103103
)) as any
104-
if (resultValue !== null) {
104+
if (resultValue === null) {
105+
await redis.set(idempotenceKey, '0', 'EX', expired)
106+
} else {
105107
if (errorHandler) {
106108
return await errorHandler(request)
107109
}
@@ -111,8 +113,6 @@ export class IdempotenceInterceptor implements NestInterceptor {
111113
0: pendingMessage,
112114
}[resultValue]
113115
throw new ConflictException(message)
114-
} else {
115-
await redis.set(idempotenceKey, '0', 'EX', expired)
116116
}
117117
}
118118
return next.handle().pipe(
@@ -141,7 +141,7 @@ export class IdempotenceInterceptor implements NestInterceptor {
141141
const ip = getIp(req)
142142

143143
if (!ua && !ip) {
144-
return undefined
144+
return
145145
}
146146
Object.assign(obj, { ua, ip })
147147
}

apps/core/src/common/interceptors/response.interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class ResponseInterceptor<T> implements NestInterceptor<T, Response<T>> {
4444

4545
return next.handle().pipe(
4646
map((data) => {
47-
if (typeof data === 'undefined') {
47+
if (data === undefined) {
4848
context.switchToHttp().getResponse().status(204)
4949
return data
5050
}

apps/core/src/constants/path.constant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export const LOG_DIR = join(DATA_DIR, 'log')
1818
export const STATIC_FILE_DIR = join(DATA_DIR, 'static')
1919
export const STATIC_FILE_TRASH_DIR = join(TEMP_DIR, 'trash')
2020

21-
export const BACKUP_DIR = !isDev
22-
? join(DATA_DIR, 'backup')
23-
: join(TEMP_DIR, 'backup')
21+
export const BACKUP_DIR = isDev
22+
? join(TEMP_DIR, 'backup')
23+
: join(DATA_DIR, 'backup')
2424

2525
// 生产环境直接打包到 目录的 admin 下
2626
export const LOCAL_ADMIN_ASSET_PATH = isDev

apps/core/src/global/consola.global.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { LOG_DIR } from '~/constants/path.constant'
33
import { isTest } from './env.global'
44

55
const logger = createLogger({
6-
writeToFile: !isTest
7-
? {
6+
writeToFile: isTest
7+
? undefined
8+
: {
89
loggerDir: LOG_DIR,
910
errWriteToStdout: true,
10-
}
11-
: undefined,
11+
},
1212
})
1313
Logger.setLoggerInstance(logger)
1414
if (!isTest) {

apps/core/src/modules/activity/activity.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ export class ActivityController {
196196
for (const item of like.data) {
197197
const likeData = pick(item, 'created', 'id') as any
198198

199-
if (!item.ref) {
200-
likeData.title = '已删除的内容'
201-
} else {
199+
if (item.ref) {
202200
if ('nid' in item.ref) {
203201
likeData.type = CollectionRefTypes.Note
204202
likeData.nid = item.ref.nid
@@ -207,6 +205,8 @@ export class ActivityController {
207205
likeData.slug = item.ref.slug
208206
}
209207
likeData.title = item.ref.title
208+
} else {
209+
likeData.title = '已删除的内容'
210210
}
211211

212212
transformedLike.push(likeData)

apps/core/src/modules/activity/dtos/activity.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IsEnum, IsInt, IsNumber, IsOptional } from 'class-validator'
44
import { Activity } from '../activity.constant'
55

66
const TransformEnum = () =>
7-
Transform(({ value }) => (typeof value === 'undefined' ? value : +value))
7+
Transform(({ value }) => (value === undefined ? value : +value))
88

99
export class ActivityTypeParamsDto {
1010
@IsEnum(Activity)

apps/core/src/modules/aggregate/aggregate.controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ export class AggregateController {
4848
this.configsService.get('url'),
4949
this.configsService.get('seo'),
5050
this.noteService.getLatestNoteId(),
51-
!theme
52-
? Promise.resolve()
53-
: this.snippetService
51+
theme
52+
? this.snippetService
5453
.getCachedSnippet('theme', theme, 'public')
5554
.then((cached) => {
5655
if (cached) {
5756
return JSON.safeParse(cached) || cached
5857
}
5958
return this.snippetService.getPublicSnippetByName(theme, 'theme')
60-
}),
59+
})
60+
: Promise.resolve(),
6161
])
6262
const [user, categories, pageMeta, url, seo, latestNoteId, themeConfig] =
6363
tasks.map((t) => {

apps/core/src/modules/aggregate/aggregate.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,18 @@ export class AggregateService {
9797
const [notes, posts, says, recently] = await Promise.all([
9898
this.findTop(
9999
this.noteService.model,
100-
!isAuthenticated
101-
? {
100+
isAuthenticated
101+
? {}
102+
: {
102103
isPublished: true,
103104
password: undefined,
104-
}
105-
: {},
105+
},
106106
size,
107107
).lean({ getters: true }),
108108

109109
this.findTop(
110110
this.postService.model,
111-
!isAuthenticated ? { isPublished: true } : {},
111+
isAuthenticated ? {} : { isPublished: true },
112112
size,
113113
)
114114
.populate('categoryId')

0 commit comments

Comments
 (0)