chore: remove deprecated routes
This commit is contained in:
@@ -87,14 +87,6 @@ describe('test note client', () => {
|
|||||||
expect(data.title).toBe('1')
|
expect(data.title).toBe('1')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should like note', async () => {
|
|
||||||
mockResponse('/notes/like/1', null)
|
|
||||||
|
|
||||||
const data = await client.note.likeIt('1')
|
|
||||||
|
|
||||||
expect(data).toBeNull()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should forbidden if no password provide', async () => {
|
it('should forbidden if no password provide', async () => {
|
||||||
spyOn(axiosAdaptor, 'get').mockRejectedValue({
|
spyOn(axiosAdaptor, 'get').mockRejectedValue({
|
||||||
response: {
|
response: {
|
||||||
|
|||||||
@@ -66,12 +66,4 @@ describe('test post client', () => {
|
|||||||
expect(data).toStrictEqual({ title: '1' })
|
expect(data).toStrictEqual({ title: '1' })
|
||||||
expect(data.$raw).toBeDefined()
|
expect(data.$raw).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should thumbs-up post', async () => {
|
|
||||||
mockResponse('/posts/_thumbs-up?id=1', null)
|
|
||||||
|
|
||||||
const data = await client.post.thumbsUp('1')
|
|
||||||
|
|
||||||
expect(data).toBeNull()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -34,13 +34,15 @@ export const createKyAdaptor = (ky: KyInstance) => {
|
|||||||
get(url, options) {
|
get(url, options) {
|
||||||
return getDataFromKyResponse(ky.get(url, options))
|
return getDataFromKyResponse(ky.get(url, options))
|
||||||
},
|
},
|
||||||
post(url, options) {
|
async post(url, options) {
|
||||||
const data = options.data
|
const data = options.data
|
||||||
delete options.data
|
delete options.data
|
||||||
const kyOptions: Options = {
|
const kyOptions: Options = {
|
||||||
...options,
|
...options,
|
||||||
|
|
||||||
json: data,
|
json: data,
|
||||||
}
|
}
|
||||||
|
// FIXME https://github.com/sindresorhus/ky/issues/535
|
||||||
|
|
||||||
return getDataFromKyResponse(ky.post(url, kyOptions))
|
return getDataFromKyResponse(ky.post(url, kyOptions))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ import type {
|
|||||||
NoteWrappedPayload,
|
NoteWrappedPayload,
|
||||||
NoteWrappedWithLikedPayload,
|
NoteWrappedWithLikedPayload,
|
||||||
} from '~/models/note'
|
} from '~/models/note'
|
||||||
import type { HTTPClient } from '../core/client'
|
|
||||||
import type { SortOptions } from './base'
|
import type { SortOptions } from './base'
|
||||||
|
|
||||||
import { autoBind } from '~/utils/auto-bind'
|
import { autoBind } from '~/utils/auto-bind'
|
||||||
|
|
||||||
|
import { HTTPClient } from '../core/client'
|
||||||
|
|
||||||
declare module '../core/client' {
|
declare module '../core/client' {
|
||||||
interface HTTPClient<
|
interface HTTPClient<
|
||||||
T extends IRequestAdapter = IRequestAdapter,
|
T extends IRequestAdapter = IRequestAdapter,
|
||||||
@@ -110,13 +111,6 @@ export class NoteController<ResponseWrapper> implements IController {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 喜欢这篇日记
|
|
||||||
*/
|
|
||||||
likeIt(id: string | number) {
|
|
||||||
return this.proxy.like(id).get<never>()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取专栏内的所有日记
|
* 获取专栏内的所有日记
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
|||||||
import type { SelectFields } from '~/interfaces/types'
|
import type { SelectFields } from '~/interfaces/types'
|
||||||
import type { ModelWithLiked, PaginateResult } from '~/models/base'
|
import type { ModelWithLiked, PaginateResult } from '~/models/base'
|
||||||
import type { PostModel } from '~/models/post'
|
import type { PostModel } from '~/models/post'
|
||||||
import type { HTTPClient } from '../core/client'
|
|
||||||
|
|
||||||
import { autoBind } from '~/utils/auto-bind'
|
import { autoBind } from '~/utils/auto-bind'
|
||||||
|
|
||||||
|
import { HTTPClient } from '../core/client'
|
||||||
|
|
||||||
declare module '../core/client' {
|
declare module '../core/client' {
|
||||||
interface HTTPClient<
|
interface HTTPClient<
|
||||||
T extends IRequestAdapter = IRequestAdapter,
|
T extends IRequestAdapter = IRequestAdapter,
|
||||||
@@ -85,11 +86,4 @@ export class PostController<ResponseWrapper> implements IController {
|
|||||||
getLatest() {
|
getLatest() {
|
||||||
return this.proxy.latest.get<ModelWithLiked<PostModel>>()
|
return this.proxy.latest.get<ModelWithLiked<PostModel>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 点赞
|
|
||||||
*/
|
|
||||||
thumbsUp(id: string) {
|
|
||||||
return this.proxy('_thumbs-up').get<void>({ params: { id } })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
"cors": "2.8.5",
|
"cors": "2.8.5",
|
||||||
"express": "4.18.2",
|
"express": "4.18.2",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
"ky": "0.33.3",
|
"ky": "1.1.0",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"tsup": "7.2.0",
|
"tsup": "7.2.0",
|
||||||
"umi-request": "1.4.0",
|
"umi-request": "1.4.0",
|
||||||
|
|||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -424,8 +424,8 @@ importers:
|
|||||||
specifier: 4.0.0
|
specifier: 4.0.0
|
||||||
version: 4.0.0
|
version: 4.0.0
|
||||||
ky:
|
ky:
|
||||||
specifier: 0.33.3
|
specifier: 1.1.0
|
||||||
version: 0.33.3
|
version: 1.1.0
|
||||||
lodash:
|
lodash:
|
||||||
specifier: 4.17.21
|
specifier: 4.17.21
|
||||||
version: 4.17.21
|
version: 4.17.21
|
||||||
@@ -5548,9 +5548,9 @@ packages:
|
|||||||
json-buffer: 3.0.1
|
json-buffer: 3.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/ky@0.33.3:
|
/ky@1.1.0:
|
||||||
resolution: {integrity: sha512-CasD9OCEQSFIam2U8efFK81Yeg8vNMTBUqtMOHlrcWQHqUX3HeCl9Dr31u4toV7emlH8Mymk5+9p0lL6mKb/Xw==}
|
resolution: {integrity: sha512-n/rS/Yw+pc/j61kl353yIhxpM/FN0VidhPeiMv6Y/QyyCUpSJtHtHlX655wYolZ/Wc3BKO4Q5syWKfzJ5CT7Bg==}
|
||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=18'}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/levn@0.4.1:
|
/levn@0.4.1:
|
||||||
|
|||||||
Reference in New Issue
Block a user