fix: lint and fix cache service
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
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,
|
||||
|
||||
Reference in New Issue
Block a user