fix: lint and fix cache service

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-04-06 22:18:48 +08:00
parent 128b92cbee
commit 96263782d0
68 changed files with 139 additions and 219 deletions

File diff suppressed because one or more lines are too long

View File

@@ -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`

View File

@@ -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',

View File

@@ -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) => {

View File

@@ -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'

View File

@@ -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}'`,
),

View File

@@ -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,

View File

@@ -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"
},

View File

@@ -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

View File

@@ -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/*",

View File

@@ -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)

View File

@@ -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,