fix: lint and fix cache service
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
4
.github/workflows/api-client.yml
vendored
4
.github/workflows/api-client.yml
vendored
@@ -10,12 +10,12 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- 'packages/api-client/**'
|
||||
- '.github/workflows/api-client.yml'
|
||||
- .github/workflows/api-client.yml
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
paths:
|
||||
- 'packages/api-client/**'
|
||||
- '.github/workflows/api-client.yml'
|
||||
- .github/workflows/api-client.yml
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -3,7 +3,7 @@ on:
|
||||
tags-ignore:
|
||||
- 'v*'
|
||||
paths-ignore:
|
||||
- 'CHANGELOG.MD'
|
||||
- CHANGELOG.MD
|
||||
branches: master
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -95,7 +95,7 @@ jobs:
|
||||
name: Download release
|
||||
with:
|
||||
tag: ${{ github.ref_name }}
|
||||
fileName: 'release-linux.zip'
|
||||
fileName: release-linux.zip
|
||||
- name: copy file via ssh password
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
@@ -104,8 +104,8 @@ jobs:
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
# port: ${{ secrets.PORT }}
|
||||
key: ${{ secrets.KEY }}
|
||||
source: 'release-linux.zip'
|
||||
target: '/tmp/mx-core'
|
||||
source: release-linux.zip
|
||||
target: /tmp/mx-core
|
||||
|
||||
- name: Exec deploy script with SSH
|
||||
uses: appleboy/ssh-action@master
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
arch: ['amd64']
|
||||
arch: [amd64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -13,12 +13,10 @@
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"material-icon-theme.activeIconPack": "nest",
|
||||
"cSpell.words": [
|
||||
"qaqdmin"
|
||||
],
|
||||
"cSpell.words": ["qaqdmin"],
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"yaml.schemas": {
|
||||
"https://json.schemastore.org/github-workflow.json": "file:///Users/xiaoxun/github/innei-repo/mx-space/mx-server/.github/workflows/build.yml"
|
||||
},
|
||||
"typescript.preferences.preferTypeOnlyAutoImports": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!env node
|
||||
const { appendFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
const { appendFileSync } = require('node:fs')
|
||||
const { join } = require('node:path')
|
||||
const { fetch, $ } = require('zx-cjs')
|
||||
const {
|
||||
dashboard: { repo, version },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!env node
|
||||
const { appendFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
const { appendFileSync } = require('node:fs')
|
||||
const { join } = require('node:path')
|
||||
const { fetch, $ } = require('zx-cjs')
|
||||
const {
|
||||
dashboard: { repo, version },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { execSync } = require('child_process')
|
||||
const { execSync } = require('node:child_process')
|
||||
const nodePath = execSync(`npm root --quiet -g`, { encoding: 'utf-8' }).split(
|
||||
'\n',
|
||||
)[0]
|
||||
|
||||
@@ -20,7 +20,6 @@ import { IpLocation, IpRecord } from './common/decorators/ip.decorator'
|
||||
import { AllowAllCorsInterceptor } from './common/interceptors/allow-all-cors.interceptor'
|
||||
import { RedisKeys } from './constants/cache.constant'
|
||||
import { OptionModel } from './modules/configs/configs.model'
|
||||
import { CacheService } from './processors/redis/cache.service'
|
||||
import { RedisService } from './processors/redis/redis.service'
|
||||
import { getRedisKey } from './utils/redis.util'
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { performance } from 'node:perf_hooks'
|
||||
import wcmatch from 'wildcard-match'
|
||||
import type { FastifyCorsOptions } from '@fastify/cors'
|
||||
import type { LogLevel } from '@nestjs/common'
|
||||
import type { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface'
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify'
|
||||
|
||||
import { Logger } from '@innei/pretty-logger-nestjs'
|
||||
|
||||
@@ -23,7 +23,6 @@ import * as SYSTEM from '~/constants/system.constant'
|
||||
import { REFLECTOR } from '~/constants/system.constant'
|
||||
import { AnalyzeModel } from '~/modules/analyze/analyze.model'
|
||||
import { OptionModel } from '~/modules/configs/configs.model'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { getNestExecutionContextRequest } from '~/transformers/get-req.transformer'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
HTTP_IDEMPOTENCE_OPTIONS,
|
||||
} from '~/constants/meta.constant'
|
||||
import { REFLECTOR } from '~/constants/system.constant'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { getIp } from '~/utils/ip.util'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
|
||||
export enum BusinessEvents {
|
||||
GATEWAY_CONNECT = 'GATEWAY_CONNECT',
|
||||
GATEWAY_DISCONNECT = 'GATEWAY_DISCONNECT',
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { omit, pick, uniqBy } from 'lodash'
|
||||
import { ObjectId } from 'mongodb'
|
||||
import { Types } from 'mongoose'
|
||||
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'
|
||||
import type { Collection } from 'mongodb'
|
||||
import type { Document } from 'mongoose'
|
||||
import type { Socket } from 'socket.io'
|
||||
import type { NoteModel } from '../note/note.model'
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
import { EventBusEvents } from '~/constants/event-bus.constant'
|
||||
import { WebEventsGateway } from '~/processors/gateway/web/events.gateway'
|
||||
import { UrlBuilderService } from '~/processors/helper/helper.url-builder.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { addYearCondition } from '~/transformers/db-query.transformer'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
@@ -10,7 +10,6 @@ import { BusinessEvents } from '~/constants/business-event.constant'
|
||||
import { CollectionRefTypes } from '~/constants/db.constant'
|
||||
import { ErrorCodeEnum } from '~/constants/error-code.constant'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
import { transformDataToPaginate } from '~/transformers/paginate.transformer'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { OpenAI } from 'openai'
|
||||
import type { ChatModel } from 'openai/resources'
|
||||
|
||||
export const DEFAULT_SUMMARY_LANG = 'zh'
|
||||
|
||||
@@ -7,7 +7,6 @@ import { ApiController } from '~/common/decorators/api-controller.decorator'
|
||||
import { Auth } from '~/common/decorators/auth.decorator'
|
||||
import { Paginator } from '~/common/decorators/http.decorator'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { getTodayEarly, getWeekStart } from '~/utils/time.util'
|
||||
|
||||
@@ -6,7 +6,6 @@ import { Injectable } from '@nestjs/common'
|
||||
import { ReturnModelType } from '@typegoose/typegoose'
|
||||
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
@@ -21,7 +21,7 @@ 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 { RedisService } from '~/processors/redis/redis.service'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
@@ -38,7 +38,7 @@ export class AuthnService {
|
||||
@InjectModel(AuthnModel)
|
||||
private readonly authnModel: ReturnModelType<typeof AuthnModel>,
|
||||
|
||||
private readonly cacheService: CacheService,
|
||||
private readonly redisService: RedisService,
|
||||
private readonly configService: ConfigsService,
|
||||
) {}
|
||||
|
||||
@@ -109,16 +109,14 @@ export class AuthnService {
|
||||
}
|
||||
|
||||
private async setCurrentChallenge(challenge: string) {
|
||||
await this.cacheService.set(
|
||||
getRedisKey(RedisKeys.Authn),
|
||||
challenge,
|
||||
// 5 min
|
||||
1000 * 60 * 5,
|
||||
)
|
||||
const redisClient = this.redisService.getClient()
|
||||
await redisClient.set(getRedisKey(RedisKeys.Authn), challenge)
|
||||
// 5 min
|
||||
await redisClient.expire(getRedisKey(RedisKeys.Authn), 1000 * 60 * 5)
|
||||
}
|
||||
|
||||
private async getCurrentChallenge() {
|
||||
return await this.cacheService.get<string>(getRedisKey(RedisKeys.Authn))
|
||||
return await this.redisService.getClient().get(getRedisKey(RedisKeys.Authn))
|
||||
}
|
||||
|
||||
async verifyRegistrationResponse(
|
||||
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
import { BACKUP_DIR, DATA_DIR } from '~/constants/path.constant'
|
||||
import { migrateDatabase } from '~/migration/migrate'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { scheduleManager } from '~/utils/schedule.util'
|
||||
import { getFolderSize, installPKG } from '~/utils/system.util'
|
||||
|
||||
@@ -16,7 +16,7 @@ marked.use({
|
||||
)}\n</span>`
|
||||
},
|
||||
tokenizer(src) {
|
||||
const rule = /^\|\|([\S\s]+?)\|\|(?!\|)/
|
||||
const rule = /^\|\|([\s\S]+?)\|\|(?!\|)/
|
||||
const match = rule.exec(src)
|
||||
if (match) {
|
||||
return {
|
||||
@@ -39,7 +39,7 @@ marked.use({
|
||||
return `<span class="katex-render">${token.text}</span>`
|
||||
},
|
||||
tokenizer(src) {
|
||||
const rule = /^\$([\S\s]+?)\$(?!\$)/
|
||||
const rule = /^\$([\s\S]+?)\$(?!\$)/
|
||||
const match = rule.exec(src)
|
||||
if (match) {
|
||||
return {
|
||||
@@ -71,7 +71,7 @@ marked.use({
|
||||
},
|
||||
tokenizer(src) {
|
||||
const rule =
|
||||
/^{((?<prefix>(GH)|(TW)|(TG))@(?<name>\w+\b))}\s?(?!\[.*?])/
|
||||
/^\{((?<prefix>(GH)|(TW)|(TG))@(?<name>\w+\b))\}\s?(?!\[.*?\])/
|
||||
const match = rule.exec(src)
|
||||
if (match) {
|
||||
const { groups } = match
|
||||
|
||||
@@ -43,7 +43,7 @@ export class PageProxyController {
|
||||
}
|
||||
const log = this.fetchLogs.pop() || '...'
|
||||
|
||||
reply.code(200).type('text/html').send(`${log}`)
|
||||
reply.code(200).type('text/html').send(String(log))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CollectionRefTypes } from '~/constants/db.constant'
|
||||
import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
@@ -14,8 +14,8 @@ async function handler() {
|
||||
|
||||
const { BiliClient } = extra
|
||||
const bl = await context.getMaster().then((user) => user.socialIds.bilibili)
|
||||
const client = new BiliClient(parseInt(bl || uid))
|
||||
const bangumi = await client.getFavoriteBangumi(parseInt(len))
|
||||
const client = new BiliClient(Number.parseInt(bl || uid))
|
||||
const bangumi = await client.getFavoriteBangumi(Number.parseInt(len))
|
||||
return bangumi
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ const len = 10
|
||||
|
||||
```js
|
||||
// require built-in module
|
||||
const path = await require('path') // ok
|
||||
const path = await require('node:path') // ok
|
||||
// `os` `sys` module is banned, because is dangerous
|
||||
const os = await require('os') // error
|
||||
const os = await require('node:os') // error
|
||||
|
||||
// require third module, you can require some trusted third party modules.
|
||||
const axios = await require('axios') // ok, but you must install this module in data_dir/node_modules or other NODE_PATH
|
||||
@@ -71,11 +71,8 @@ const remoteModule =
|
||||
用法如下:
|
||||
|
||||
```ts
|
||||
import axios from 'axios'
|
||||
// this is ok, will transformer to `var axios = await require('axios')`
|
||||
import { render } from 'ejs'
|
||||
// ok, transform to var _ejs = await require("ejs"); _ejs.render
|
||||
import * as ejs from 'ejs'
|
||||
|
||||
// bad, don't recommend
|
||||
```
|
||||
|
||||
@@ -34,7 +34,6 @@ import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { AssetService } from '~/processors/helper/helper.asset.service'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import { HttpService } from '~/processors/helper/helper.http.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
import { EncryptUtil } from '~/utils/encrypt.util'
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable import/no-duplicates */
|
||||
import type { TransformOptions } from '@babel/core'
|
||||
import type * as t from '@babel/types'
|
||||
import type { VariableDeclaration } from '@babel/types'
|
||||
|
||||
@@ -17,7 +17,6 @@ import { EventScope } from '~/constants/business-event.constant'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { EventBusEvents } from '~/constants/event-bus.constant'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { InjectModel } from '~/transformers/model.transformer'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from 'class-validator'
|
||||
import slugify from 'slugify'
|
||||
|
||||
import { index, modelOptions, prop } from '@typegoose/typegoose'
|
||||
import { modelOptions, prop } from '@typegoose/typegoose'
|
||||
|
||||
import { TOPIC_COLLECTION_NAME } from '~/constants/db.constant'
|
||||
import { BaseModel } from '~/shared/model/base.model'
|
||||
|
||||
@@ -11,7 +11,6 @@ import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { safeJSONParse } from '~/utils/tool.util'
|
||||
|
||||
import { CacheService } from '../redis/cache.service'
|
||||
import { RedisService } from '../redis/redis.service'
|
||||
|
||||
export type SocketType =
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
import { EventBusEvents } from '~/constants/event-bus.constant'
|
||||
import { AuthService } from '~/modules/auth/auth.service'
|
||||
import { JWTService } from '~/processors/helper/helper.jwt.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
|
||||
import { BusinessEvents } from '../../../constants/business-event.constant'
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
|
||||
import { BusinessEvents } from '~/constants/business-event.constant'
|
||||
import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { scheduleManager } from '~/utils/schedule.util'
|
||||
|
||||
@@ -6,7 +6,6 @@ import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
import { DatabaseService } from '../database/database.service'
|
||||
import { CacheService } from '../redis/cache.service'
|
||||
import { RedisService } from '../redis/redis.service'
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -10,7 +10,6 @@ import { RedisKeys } from '~/constants/cache.constant'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
|
||||
import { version } from '../../../package.json'
|
||||
import { CacheService } from '../redis/cache.service'
|
||||
import { RedisService } from '../redis/redis.service'
|
||||
|
||||
const DEFAULT_UA = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 MX-Space/${version}`
|
||||
|
||||
@@ -9,7 +9,6 @@ import { logger } from '~/global/consola.global'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { md5 } from '~/utils/tool.util'
|
||||
|
||||
import { CacheService } from '../redis/cache.service'
|
||||
import { RedisService } from '../redis/redis.service'
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Injectable } from '@nestjs/common'
|
||||
|
||||
import { safeJSONParse } from '~/utils/tool.util'
|
||||
|
||||
import { CacheService } from '../redis/cache.service'
|
||||
import { RedisService } from '../redis/redis.service'
|
||||
|
||||
type ITask = RedisMap<
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
import { Cache } from 'cache-manager'
|
||||
import type { Redis } from 'ioredis'
|
||||
|
||||
import KeyvRedis from '@keyv/redis'
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager'
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Emitter } from '@socket.io/redis-emitter'
|
||||
|
||||
import { RedisIoAdapterKey } from '~/common/adapters/socket.adapter'
|
||||
import { API_CACHE_PREFIX } from '~/constants/cache.constant'
|
||||
import { getRedisKey } from '~/utils/redis.util'
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
|
||||
// Cache 客户端管理器
|
||||
|
||||
@@ -23,11 +16,11 @@ export type TCacheResult<T> = Promise<T | null>
|
||||
* @example CacheService.set(CacheKey).then()
|
||||
*/
|
||||
@Injectable()
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export class CacheService {
|
||||
private cache!: Cache
|
||||
private logger = new Logger(CacheService.name)
|
||||
|
||||
private ioRedis!: Redis
|
||||
constructor(@Inject(CACHE_MANAGER) cache: Cache) {
|
||||
this.cache = cache
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import type {
|
||||
CacheModuleOptions,
|
||||
CacheOptionsFactory,
|
||||
} from '@nestjs/cache-manager'
|
||||
import type { RedisOptions } from 'ioredis'
|
||||
|
||||
import Keyv from '@keyv/redis'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import IORedis from 'ioredis'
|
||||
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { Emitter } from '@socket.io/redis-emitter'
|
||||
|
||||
import { REDIS } from '~/app.config'
|
||||
@@ -11,7 +11,6 @@ import { getRedisKey } from '~/utils/redis.util'
|
||||
@Injectable()
|
||||
export class RedisService {
|
||||
private redisClient: IORedis
|
||||
private logger = new Logger(RedisService.name)
|
||||
constructor() {
|
||||
this.redisClient = new IORedis({
|
||||
host: REDIS.host,
|
||||
|
||||
@@ -2,8 +2,6 @@ import { defineProvider } from 'test/helper/defineProvider'
|
||||
|
||||
import { redisHelper } from '@/helper/redis-mock.helper'
|
||||
|
||||
import { generateDefaultConfig } from '~/modules/configs/configs.default'
|
||||
import { ConfigsService } from '~/modules/configs/configs.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
|
||||
export const createRedisProvider = async () =>
|
||||
|
||||
@@ -13,7 +13,6 @@ import { OptionModel } from '~/modules/configs/configs.model'
|
||||
import { ConfigsService } from '~/modules/configs/configs.service'
|
||||
import { UserService } from '~/modules/user/user.service'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { SubPubBridgeService } from '~/processors/redis/subpub.service'
|
||||
import { getModelToken } from '~/transformers/model.transformer'
|
||||
|
||||
@@ -12,7 +12,6 @@ import { DatabaseService } from '~/processors/database/database.service'
|
||||
import { AssetService } from '~/processors/helper/helper.asset.service'
|
||||
import { EventManagerService } from '~/processors/helper/helper.event.service'
|
||||
import { HttpService } from '~/processors/helper/helper.http.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { RedisService } from '~/processors/redis/redis.service'
|
||||
import { getModelToken } from '~/transformers/model.transformer'
|
||||
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"esModuleInterop": true,
|
||||
"strictNullChecks": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2022",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"noEmit": true,
|
||||
"allowJs": true,
|
||||
"baseUrl": "..",
|
||||
"noImplicitAny": false,
|
||||
"incremental": true,
|
||||
"resolveJsonModule": true,
|
||||
"target": "es2022",
|
||||
"lib": [
|
||||
"ES2021",
|
||||
"es2020"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"baseUrl": "..",
|
||||
"module": "CommonJS",
|
||||
"paths": {
|
||||
"~": [
|
||||
"./src"
|
||||
@@ -35,7 +23,19 @@
|
||||
"@/*": [
|
||||
"./test/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": false,
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "./dist",
|
||||
"sourceMap": true,
|
||||
"noEmit": true,
|
||||
"noImplicitAny": false,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*.ts",
|
||||
|
||||
@@ -4,10 +4,5 @@
|
||||
"declaration": false,
|
||||
"sourceMap": false
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"test",
|
||||
"dist",
|
||||
"**/*spec.ts"
|
||||
]
|
||||
}
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import fs, { statSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import fs, { statSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
const srcDir = resolve(process.cwd(), 'src')
|
||||
|
||||
@@ -20,10 +20,10 @@ function walkDir(dir: string) {
|
||||
} else if (stat.isFile() && filePath.endsWith('.ts')) {
|
||||
const content = fs.readFileSync(filePath, 'utf-8')
|
||||
|
||||
const newContent = content.replace(/from '(.*)'/g, (match, p1) => {
|
||||
const newContent = content.replaceAll(/from '(.*)'/g, (match, p1) => {
|
||||
// if is startswith alphabet or @, this is a library path, return it
|
||||
|
||||
if (p1.startsWith('@') || /^[a-zA-Z]/.test(p1)) {
|
||||
if (p1.startsWith('@') || /^[a-z]/i.test(p1)) {
|
||||
return match
|
||||
}
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const webpack = require('webpack')
|
||||
|
||||
const { resolve } = require('path')
|
||||
const { resolve } = require('node:path')
|
||||
module.exports = function (options) {
|
||||
options.plugins = (options.plugins || []).concat(
|
||||
new webpack.DefinePlugin({
|
||||
|
||||
@@ -20,7 +20,7 @@ services:
|
||||
- mx-space
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://127.0.0.1:2333/api/v2/ping']
|
||||
test: [CMD, curl, -f, 'http://127.0.0.1:2333/api/v2/ping']
|
||||
interval: 1m30s
|
||||
timeout: 30s
|
||||
retries: 5
|
||||
@@ -41,7 +41,7 @@ services:
|
||||
volumes:
|
||||
- ./data/redis:/data
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'redis-cli ping | grep PONG']
|
||||
test: [CMD-SHELL, 'redis-cli ping | grep PONG']
|
||||
start_period: 20s
|
||||
interval: 30s
|
||||
retries: 5
|
||||
|
||||
@@ -61,4 +61,4 @@
|
||||
"typescript": "5.7.3",
|
||||
"whatwg-url": "14.1.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,7 +2,6 @@ import axios from 'axios'
|
||||
import type { IRequestAdapter } from '~/interfaces/adapter'
|
||||
import type { AxiosInstance, AxiosResponse } from 'axios'
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
const $http = /*#__PURE__*/ axios.create({})
|
||||
|
||||
// ignore axios `method` declare not assignable to `Method`
|
||||
|
||||
@@ -2,7 +2,6 @@ import { extend } from 'umi-request'
|
||||
import type { IRequestAdapter } from '~/interfaces/adapter'
|
||||
import type { RequestMethod, RequestResponse } from 'umi-request'
|
||||
|
||||
// eslint-disable-next-line spaced-comment
|
||||
const $http = /*#__PURE__*/ extend({
|
||||
getResponse: true,
|
||||
requestType: 'json',
|
||||
|
||||
@@ -7,7 +7,7 @@ export function attachRequestMethod<T extends HTTPClient<any, any>>(target: T) {
|
||||
const { params = {}, ...rest } = options
|
||||
const qs = handleSearchParams(params)
|
||||
|
||||
return target.instance.get(`${url}${qs ? `${`?${qs}`}` : ''}`, rest)
|
||||
return target.instance.get(`${url}${qs ? String(`?${qs}`) : ''}`, rest)
|
||||
},
|
||||
})
|
||||
;(['put', 'post', 'patch', 'delete'] as const).forEach((method) => {
|
||||
|
||||
@@ -8,6 +8,5 @@ export { createClient, RequestError } from './core'
|
||||
export type { HTTPClient } from './core'
|
||||
export { camelcaseKeys as simpleCamelcaseKeys } from './utils/camelcase-keys'
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default createClient
|
||||
export type { IRequestAdapter } from './interfaces/adapter'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { readFileSync, writeFileSync } from 'fs'
|
||||
import path from 'path'
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
const __dirname = new URL(import.meta.url).pathname.replace(/\/[^/]*$/, '')
|
||||
const PKG = JSON.parse(readFileSync(path.resolve(__dirname, './package.json')))
|
||||
@@ -11,7 +11,7 @@ const content = readFileSync(dts, 'utf-8')
|
||||
// with declare module '@mx-space/api-client'
|
||||
writeFileSync(
|
||||
dts,
|
||||
content.replace(
|
||||
content.replaceAll(
|
||||
/declare module '..\/core\/client'/g,
|
||||
'declare module ' + `'${PKG.name}'`,
|
||||
),
|
||||
|
||||
@@ -28,11 +28,9 @@ export interface Url {
|
||||
webUrl: string
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AggregateTopNote
|
||||
extends Pick<NoteModel, 'id' | 'title' | 'created' | 'nid' | 'images'> {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AggregateTopPost
|
||||
extends Pick<
|
||||
PostModel,
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"name": "@mx-space/api-client",
|
||||
"version": "1.16.1",
|
||||
"type": "module",
|
||||
"description": "A api client for mx-space server@next",
|
||||
"author": "Innei",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Innei",
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.js"
|
||||
},
|
||||
"./dist/*": {
|
||||
"import": "./dist/*.js",
|
||||
"require": "./dist/*.cjs"
|
||||
"require": "./dist/*.cjs",
|
||||
"import": "./dist/*.js"
|
||||
},
|
||||
"./dist/adaptors/*": {
|
||||
"import": "./dist/adaptors/*.js",
|
||||
"require": "./dist/adaptors/*.cjs"
|
||||
"require": "./dist/adaptors/*.cjs",
|
||||
"import": "./dist/adaptors/*.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
```ts
|
||||
import {
|
||||
AggregateController,
|
||||
allControllers, // ...
|
||||
CategoryController,
|
||||
createClient,
|
||||
NoteController,
|
||||
PostController,
|
||||
allControllers, // ...
|
||||
createClient,
|
||||
} from '@mx-space/api-client'
|
||||
import { axiosAdaptor } from '@mx-space/api-client/adaptors/axios'
|
||||
|
||||
@@ -44,7 +44,7 @@ $axios.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = getToken()
|
||||
if (token) {
|
||||
config.headers!['Authorization'] = 'bearer ' + getToken()
|
||||
config.headers!.Authorization = `bearer ${ getToken()}`
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "./esm",
|
||||
"baseUrl": ".",
|
||||
"jsx": "react",
|
||||
"target": "es2020",
|
||||
"jsx": "react",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
"baseUrl": ".",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"sourceMap": true,
|
||||
"paths": {
|
||||
"~/*": [
|
||||
"*"
|
||||
@@ -25,7 +17,15 @@
|
||||
"@core/*": [
|
||||
"../../apps/core/src/*"
|
||||
],
|
||||
}
|
||||
},
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"outDir": "./esm",
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": [
|
||||
"esm/*",
|
||||
|
||||
@@ -25,5 +25,4 @@ export function camelcase(str: string) {
|
||||
return $1.toUpperCase().replace('-', '').replace('_', '')
|
||||
})
|
||||
}
|
||||
const isMongoId = (id: string) =>
|
||||
id.length === 24 && /^[\dA-Fa-f]{24}$/.test(id)
|
||||
const isMongoId = (id: string) => id.length === 24 && /^[\dA-F]{24}$/i.test(id)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import tsPath from 'vite-tsconfig-paths'
|
||||
import { defineConfig } from 'vitest/config'
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
"nanoid": "5.1.5",
|
||||
"zx": "7.2.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"outDir": "./esm",
|
||||
"baseUrl": ".",
|
||||
"jsx": "react",
|
||||
"target": "es2020",
|
||||
"jsx": "react",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
"baseUrl": ".",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"sourceMap": true,
|
||||
"paths": {
|
||||
"~/*": [
|
||||
"*"
|
||||
@@ -25,7 +17,15 @@
|
||||
"@core/*": [
|
||||
"../../apps/core/src/*"
|
||||
],
|
||||
}
|
||||
},
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"outDir": "./esm",
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": [
|
||||
"esm/*",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// const fs = require('fs')
|
||||
// const path = require('path')
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import prettier from 'prettier'
|
||||
import ts from 'typescript'
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
// Function to replace content in a file
|
||||
function replaceContent(filePath, searchValue, replaceValue) {
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"baseUrl": ".",
|
||||
"target": "es2020",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
],
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"baseUrl": ".",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"strict": false,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"sourceMap": true,
|
||||
"paths": {
|
||||
"~/*": [
|
||||
"../../apps/core/src/*"
|
||||
@@ -25,6 +18,13 @@
|
||||
"@core/*": [
|
||||
"../../apps/core/src/*"
|
||||
],
|
||||
}
|
||||
},
|
||||
"resolveJsonModule": true,
|
||||
"strict": false,
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
}
|
||||
@@ -9,12 +9,8 @@
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"updateTypes": [
|
||||
"major"
|
||||
],
|
||||
"labels": [
|
||||
"UPDATE-MAJOR"
|
||||
]
|
||||
"updateTypes": ["major"],
|
||||
"labels": ["UPDATE-MAJOR"]
|
||||
}
|
||||
],
|
||||
"ignoreDeps": [
|
||||
@@ -28,4 +24,4 @@
|
||||
"@algolia/client-search"
|
||||
],
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ function getOsBuildAssetName() {
|
||||
return `release-${os}.zip`
|
||||
}
|
||||
|
||||
const { appendFileSync } = require('fs')
|
||||
const { appendFileSync } = require('node:fs')
|
||||
|
||||
async function main() {
|
||||
const res = await fetch(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-check
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { execSync } from 'node:child_process'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { chalk } from 'zx-cjs'
|
||||
|
||||
async function main() {
|
||||
@@ -22,8 +22,8 @@ async function main() {
|
||||
console.log(cmd)
|
||||
try {
|
||||
execSync(cmd)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.log('git clone assets repo failed, please check your network')
|
||||
|
||||
process.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user