@@ -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",
|
||||
@@ -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",
|
||||
@@ -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/class-validator-jsonschema@3.1.2",
|
||||
"cls-hooked": "^4.2.2",
|
||||
"commander": "12.1.0",
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -170,4 +170,4 @@
|
||||
"mongodb-memory-server": "^10.0.0",
|
||||
"redis-memory-server": "^0.11.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
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'
|
||||
@@ -10,6 +9,7 @@ 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)
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
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'
|
||||
@@ -19,16 +19,16 @@ 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 {
|
||||
@@ -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(
|
||||
@@ -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 } }],
|
||||
|
||||
@@ -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,
|
||||
@@ -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 {
|
||||
@@ -50,7 +50,7 @@ export class SyncService {
|
||||
|
||||
private getCollections(): Record<
|
||||
SyncableCollectionName,
|
||||
Collection<Document>
|
||||
Collection<OptionalId<Document>>
|
||||
> {
|
||||
const db = this.databaseService.db
|
||||
return {
|
||||
|
||||
@@ -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'
|
||||
@@ -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 {
|
||||
@@ -192,7 +192,7 @@ export class DatabaseService {
|
||||
}
|
||||
|
||||
public get db() {
|
||||
return this.connection.db
|
||||
return this.connection.db!
|
||||
}
|
||||
|
||||
public get mongooseConnection() {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ export const getDatabaseConnection = async () => {
|
||||
|
||||
databaseConnection = await connection()
|
||||
|
||||
return databaseConnection!
|
||||
return databaseConnection
|
||||
}
|
||||
|
||||
export const normalizeRefType = (type: keyof typeof CollectionRefTypes) => {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
581
pnpm-lock.yaml
generated
581
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,9 @@
|
||||
"vitest",
|
||||
"vite",
|
||||
"snakecase-keys",
|
||||
"zx"
|
||||
"zx",
|
||||
"algoliasearch",
|
||||
"@algolia/client-search"
|
||||
],
|
||||
"enabled": true
|
||||
}
|
||||
Reference in New Issue
Block a user