Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Aug 15, 2024
1 parent 08e8f2f commit 4e63cf1
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 375 deletions.
14 changes: 7 additions & 7 deletions apps/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@algolia/client-search": "^4.22.1",
"@aws-sdk/client-s3": "3.624.0",
"@aws-sdk/client-s3": "3.631.0",
"@babel/core": "7.25.2",
"@babel/plugin-transform-modules-commonjs": "7.24.8",
"@babel/plugin-transform-typescript": "7.25.2",
Expand All @@ -70,7 +70,7 @@
"@nestjs/platform-fastify": "10.4.1",
"@nestjs/platform-socket.io": "10.4.1",
"@nestjs/schedule": "4.1.0",
"@nestjs/throttler": "6.0.0",
"@nestjs/throttler": "6.1.1",
"@nestjs/websockets": "10.4.1",
"@simplewebauthn/server": "10.0.1",
"@socket.io/redis-adapter": "8.3.0",
Expand All @@ -85,7 +85,7 @@
"cache-manager": "5.7.6",
"cache-manager-ioredis-yet": "2.1.1",
"class-transformer": "0.5.1",
"class-validator": "0.13.2",
"class-validator": "0.14.1",
"class-validator-jsonschema": "npm:@innei/[email protected]",
"cls-hooked": "^4.2.2",
"commander": "12.1.0",
Expand All @@ -104,10 +104,10 @@
"linkedom": "0.18.4",
"lodash": "^4.17.21",
"lru-cache": "11.0.0",
"marked": "13.0.3",
"marked": "14.0.0",
"mime-types": "^2.1.35",
"mkdirp": "^3.0.1",
"mongoose": "8.5.2",
"mongoose": "8.5.3",
"mongoose-aggregate-paginate-v2": "1.1.2",
"mongoose-autopopulate": "1.1.0",
"mongoose-lean-getters": "2.1.1",
Expand Down Expand Up @@ -148,7 +148,7 @@
"@types/lodash": "4.17.7",
"@types/mime-types": "2.1.4",
"@types/mongoose-aggregate-paginate-v2": "1.0.12",
"@types/node": "20.14.15",
"@types/node": "22.3.0",
"@types/nodemailer": "6.4.15",
"@types/qs": "6.9.15",
"@types/remove-markdown": "0.3.4",
Expand All @@ -170,4 +170,4 @@
"mongodb-memory-server": "^10.0.0",
"redis-memory-server": "^0.11.0"
}
}
}
17 changes: 8 additions & 9 deletions apps/core/src/migration/helper/encrypt-configs.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { plainToInstance } from 'class-transformer'

import 'reflect-metadata'

import { ENCRYPT } from '~/app.config'

import { register } from '~/global/index.global'
import { generateDefaultConfig } from '~/modules/configs/configs.default'
import * as optionDtos from '~/modules/configs/configs.dto'
import { encryptObject } from '~/modules/configs/configs.encrypt.util'
import { IConfig } from '~/modules/configs/configs.interface'
import { getDatabaseConnection } from '~/utils/database.util'
import type { IConfigKeys } from '~/modules/configs/configs.interface'
import 'reflect-metadata'

console.log(ENCRYPT)

Expand All @@ -27,14 +27,13 @@ Object.entries(optionDtos).reduce((obj, [key, value]) => {
async function main() {
await register()
const connection = await getDatabaseConnection()
const db = connection.db
const db = connection.db!
const configs: any[] = []
await db
.collection('options')
.find()
.forEach((current) => {
configs.push(current)
})
const ret = db.collection('options').find()

for await (const current of ret) {
configs.push(current)
}

const mergedConfig = generateDefaultConfig()
configs.forEach((field) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/migration/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import VersionList from './history'

export async function migrateDatabase() {
const connection = await getDatabaseConnection()
const db = connection.db
const db = connection.db!

const migrateArr = await db
.collection(MIGRATE_COLLECTION_NAME)
Expand Down
17 changes: 8 additions & 9 deletions apps/core/src/modules/authn/authn.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@ import {
verifyAuthenticationResponse,
verifyRegistrationResponse,
} from '@simplewebauthn/server'
import { ReturnModelType } from '@typegoose/typegoose'
import { isoBase64URL, isoUint8Array } from '@simplewebauthn/server/helpers'
import { ReturnModelType } from '@typegoose/typegoose'

import { RequestContext } from '~/common/contexts/request.context'
import { RedisKeys } from '~/constants/cache.constant'
import { CacheService } from '~/processors/redis/cache.service'
import { InjectModel } from '~/transformers/model.transformer'
import { getRedisKey } from '~/utils'

import { RequestContext } from '~/common/contexts/request.context'
import { getRedisKey } from '~/utils'
import { ConfigsService } from '../configs/configs.service'
import { AuthnModel } from './authn.model'
import type { UserDocument } from '../user/user.model'
import { AuthnModel } from './authn.model'
import type {
VerifiedAuthenticationResponse,
VerifiedRegistrationResponse,
} from '@simplewebauthn/server'
import type {
AuthenticationResponseJSON,
CredentialDeviceType,
RegistrationResponseJSON,
} from '@simplewebauthn/server/script/deps'
import type {
VerifiedAuthenticationResponse,
VerifiedRegistrationResponse,
} from '@simplewebauthn/server'

// TODO Compatible with versions below node v20
if (!globalThis.crypto) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
globalThis.crypto = require('node:crypto').webcrypto
}
@Injectable()
Expand Down
20 changes: 10 additions & 10 deletions apps/core/src/modules/search/search.service.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import algoliasearch from 'algoliasearch'
import { omit } from 'lodash'
import removeMdCodeblock from 'remove-md-codeblock'

import {
BadRequestException,
forwardRef,
Inject,
Injectable,
Logger,
forwardRef,
} from '@nestjs/common'
import { OnEvent } from '@nestjs/event-emitter'
import { CronExpression } from '@nestjs/schedule'

import algoliasearch from 'algoliasearch'
import { omit } from 'lodash'
import removeMdCodeblock from 'remove-md-codeblock'

import { CronDescription } from '~/common/decorators/cron-description.decorator'
import { CronOnce } from '~/common/decorators/cron-once.decorator'
import { BusinessEvents } from '~/constants/business-event.constant'
import { EventBusEvents } from '~/constants/event-bus.constant'
import { DatabaseService } from '~/processors/database/database.service'
import { transformDataToPaginate } from '~/transformers/paginate.transformer'

import type { SearchDto } from '~/modules/search/search.dto'
import type { Pagination } from '~/shared/interface/paginator.interface'
import { ConfigsService } from '../configs/configs.service'
import { NoteModel } from '../note/note.model'
import { NoteService } from '../note/note.service'
import { PageService } from '../page/page.service'
import { PostModel } from '../post/post.model'
import { PostService } from '../post/post.service'
import type { SearchIndex } from 'algoliasearch'
import type { Pagination } from '~/shared/interface/paginator.interface'
import type { SearchDto } from '~/modules/search/search.dto'
import type { SearchResponse } from '@algolia/client-search'
import type { SearchIndex } from 'algoliasearch'

@Injectable()
export class SearchService {
Expand All @@ -53,7 +53,7 @@ export class SearchService {

const keywordArr = keyword
.split(/\s+/)
.map((item) => new RegExp(String(item), 'ig'))
.map((item) => new RegExp(String(item), 'gi'))

return transformDataToPaginate(
await this.noteService.model.paginate(
Expand Down Expand Up @@ -84,7 +84,7 @@ export class SearchService {
const select = '_id title created modified categoryId slug'
const keywordArr = keyword
.split(/\s+/)
.map((item) => new RegExp(String(item), 'ig'))
.map((item) => new RegExp(String(item), 'gi'))
return await this.postService.model.paginate(
{
$or: [{ title: { $in: keywordArr } }, { text: { $in: keywordArr } }],
Expand Down
10 changes: 5 additions & 5 deletions apps/core/src/modules/sync/sync.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Readable } from 'node:stream'
import { Types } from 'mongoose'

import { Inject, Injectable } from '@nestjs/common'

import { ReturnModelType } from '@typegoose/typegoose'
import { Types } from 'mongoose'

import {
CATEGORY_COLLECTION_NAME,
Expand All @@ -22,10 +22,10 @@ import { PageService } from '../page/page.service'
import { PostService } from '../post/post.service'
import { SyncUpdateModel } from '../sync-update/sync-update.model'
import { TopicService } from '../topic/topic.service'
import type { SyncableDataInteraction } from '../sync-update/sync-update.type'
import { SyncableCollectionNames } from './sync.constant'
import type { SyncableCollectionName } from './sync.constant'
import type { SyncableDataInteraction } from '../sync-update/sync-update.type'
import type { Collection, Document } from 'mongodb'
import type { Collection, Document, OptionalId } from 'mongodb'

@Injectable()
export class SyncService {
Expand All @@ -50,7 +50,7 @@ export class SyncService {

private getCollections(): Record<
SyncableCollectionName,
Collection<Document>
Collection<OptionalId<Document>>
> {
const db = this.databaseService.db
return {
Expand Down
6 changes: 3 additions & 3 deletions apps/core/src/processors/database/database.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable } from '@nestjs/common'
import { ReturnModelType, mongoose } from '@typegoose/typegoose'
import { mongoose, ReturnModelType } from '@typegoose/typegoose'

import { CollectionRefTypes } from '~/constants/db.constant'
import { DB_CONNECTION_TOKEN } from '~/constants/system.constant'
Expand All @@ -8,8 +8,8 @@ import { PageModel } from '~/modules/page/page.model'
import { PostModel } from '~/modules/post/post.model'
import { RecentlyModel } from '~/modules/recently/recently.model'
import { InjectModel } from '~/transformers/model.transformer'
import type { WriteBaseModel } from '~/shared/model/write-base.model'
import type { ArticleTypeEnum } from '~/constants/article.constant'
import type { WriteBaseModel } from '~/shared/model/write-base.model'

@Injectable()
export class DatabaseService {
Expand Down Expand Up @@ -192,7 +192,7 @@ export class DatabaseService {
}

public get db() {
return this.connection.db
return this.connection.db!
}

public get mongooseConnection() {
Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/utils/check-init.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDatabaseConnection } from './database.util'

export const checkInit = async () => {
const connection = await getDatabaseConnection()
const db = connection.db
const db = connection.db!
const isUserExist =
(await db.collection(USER_COLLECTION_NAME).countDocuments()) > 0

Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/utils/database.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const getDatabaseConnection = async () => {

databaseConnection = await connection()

return databaseConnection!
return databaseConnection
}

export const normalizeRefType = (type: keyof typeof CollectionRefTypes) => {
Expand Down
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default sxzz(
'unicorn/prefer-top-level-await': 0,
// readable push syntax
'unicorn/no-array-push-push': 0,
'@typescript-eslint/no-require-imports': 0,
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"semver": "7.6.3",
"pino": "./external/pino",
"get-pixels@^3>request": "./external/request",
"typescript": "5.5.4"
"typescript": "5.5.4",
"whatwg-url": "13.0.0"
}
}
Loading

0 comments on commit 4e63cf1

Please sign in to comment.