forked from spencerwooo/substats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for yuque and juejin (spencerwooo#49)
- Loading branch information
1 parent
a1d6024
commit 2ead278
Showing
8 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { SubstatsResponse } from '@/types' | ||
import { commonProviderHandler } from '.' | ||
|
||
// https://juejin.cn/user/1838039172387262 | ||
type JuejinResponse = | ||
{ | ||
err_no: number; | ||
err_msg: string; | ||
data: { | ||
follower_count: number | ||
} | ||
} | ||
|
||
export default async function juejinProvider( | ||
key: string, | ||
): Promise<SubstatsResponse> { | ||
return commonProviderHandler<JuejinResponse>({ | ||
providerName: 'juejin', | ||
queryKey: key, | ||
fetchUrl: `https://api.juejin.cn/user_api/v1/user/get?user_id=${key}`, | ||
countObjPath: 'data.follower_count', | ||
errorMessageObjPath: 'err_msg', | ||
isResponseValid: d => 'follower_count' in d.data, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { SubstatsResponse } from '@/types' | ||
import { commonProviderHandler } from '.' | ||
|
||
// https://www.yuque.com/lyndon | ||
type YuqueResponse = | ||
{ | ||
data: { | ||
followers_count: number | ||
} | ||
} | ||
|
||
export default async function yuqueProvider( | ||
key: string, | ||
): Promise<SubstatsResponse> { | ||
return commonProviderHandler<YuqueResponse>({ | ||
providerName: 'yuque', | ||
queryKey: key, | ||
fetchUrl: `https://www.yuque.com/api/users/${key}/profile?`, | ||
countObjPath: 'data.followers_count', | ||
errorMessageObjPath: '', | ||
isResponseValid: d => 'followers_count' in d.data, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,5 @@ export type SupportedProviders = | |
| 'weibo' | ||
| 'wikipediazh' | ||
| 'zhihu' | ||
| 'juejin' | ||
| 'yuque' |