Portfolio API Mods
This commit is contained in:
parent
ce4e6f5003
commit
5e4a76a0df
|
@ -6,6 +6,7 @@ export default class LastFMController extends LastfmService {
|
|||
public fetchUser = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const data = await this.user()
|
||||
console.log(data)
|
||||
res.send(makeResponse(data))
|
||||
} catch (err: any) {
|
||||
res.send(makeResponse(err.message, {}, 'Failed', true))
|
||||
|
@ -14,7 +15,7 @@ export default class LastFMController extends LastfmService {
|
|||
|
||||
public fetchTop = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const data = this.top()
|
||||
const data = await this.top()
|
||||
res.send(makeResponse(data))
|
||||
} catch (err: any) {
|
||||
res.send(makeResponse(err.message, {}, 'Failed', true))
|
||||
|
@ -23,7 +24,7 @@ export default class LastFMController extends LastfmService {
|
|||
|
||||
public fetchLoved = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const data = this.loved()
|
||||
const data = await this.loved()
|
||||
res.send(makeResponse(data))
|
||||
} catch (error: any) {
|
||||
res.send(makeResponse(error.message, {}, 'Failed', true))
|
||||
|
@ -31,7 +32,7 @@ export default class LastFMController extends LastfmService {
|
|||
}
|
||||
|
||||
public fetchCurrent = async (req: Request, res: Response) => {
|
||||
const data = this.current()
|
||||
const data = await this.current()
|
||||
res.send(data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"scripts": {
|
||||
"dev": "concurrently \"npm run dev:express\" \"npm run dev:hasura\"",
|
||||
"dev:hasura": "cd hasura && hasura --skip-update-check --envfile ../.env console",
|
||||
"dev:express": "cross-env NODE_ENV=production nodemon -x node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm index.ts --signal SIGKILL",
|
||||
"dev:express": "cross-env NODE_ENV=development nodemon -x node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm index.ts --signal SIGKILL",
|
||||
"build": "tsc",
|
||||
"start": "node --es-module-specifier-resolution=node --loader ts-node/esm ./build/index.js",
|
||||
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,scss,md}\""
|
||||
|
|
|
@ -56,6 +56,6 @@ export default class HashnodeService {
|
|||
},
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
return data.data.user
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,32 @@
|
|||
import axiosInstance from '../helpers/axios_client'
|
||||
import { configKeys } from '../'
|
||||
|
||||
const config = configKeys
|
||||
|
||||
export default class LastfmService {
|
||||
public current = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=Bravo68web&api_key=${process.env.LASTFM_API_KEY}&format=json&limit=1`
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=Bravo68web&api_key=${config.LASTFM_API_KEY}&format=json&limit=1`
|
||||
)
|
||||
return data
|
||||
}
|
||||
public user = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getInfo&user=Bravo68web&api_key=${process.env.LASTFM_API_KEY}&format=json&limit=1`
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getInfo&user=Bravo68web&api_key=${config.LASTFM_API_KEY}&format=json&limit=1`
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
public loved = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getLovedTracks&user=Bravo68web&api_key=${process.env.LASTFM_API_KEY}&format=json&limit=1`
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getLovedTracks&user=Bravo68web&api_key=${config.LASTFM_API_KEY}&format=json&limit=1`
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
public top = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getTopTracks&user=Bravo68web&api_key=${process.env.LASTFM_API_KEY}&format=json&limit=1`
|
||||
`https://ws.audioscrobbler.com/2.0/?method=user.getTopTracks&user=Bravo68web&api_key=${config.LASTFM_API_KEY}&format=json&limit=1`
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import axiosInstance from '../helpers/axios_client'
|
|||
export default class TwitterService {
|
||||
public getSelfUserProfile = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
'https://api.twitter.com/2/users/959990126687342595?user.fields=created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,url,username,verified,withheld&expansions=pinned_tweet_id&tweet.fields=attachments,author_id,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,referenced_tweets,source,text,withheld',
|
||||
'https://api.twitter.com/2/users/959990126687342595?user.fields=created_at,public_metrics,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,url,username,verified,withheld&expansions=pinned_tweet_id&tweet.fields=attachments,author_id,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,referenced_tweets,source,text,withheld',
|
||||
{
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + process.env.TWITTER_BEARER_TOKEN,
|
||||
|
|
|
@ -6,7 +6,7 @@ export default class WakatimeService {
|
|||
'https://wakatime.com/api/v1/users/current?api_key=' +
|
||||
process.env.WAKATIME_API_KEY
|
||||
)
|
||||
return data
|
||||
return data.data
|
||||
}
|
||||
|
||||
public getWakatimeCodeStatesAllTime = async () => {
|
||||
|
@ -14,7 +14,7 @@ export default class WakatimeService {
|
|||
'https://wakatime.com/api/v1/users/current/all_time_since_today?api_key=' +
|
||||
process.env.WAKATIME_API_KEY
|
||||
)
|
||||
return data
|
||||
return data.data
|
||||
}
|
||||
|
||||
public getWakatimeCodeStatsLast7Days = async () => {
|
||||
|
@ -23,8 +23,10 @@ export default class WakatimeService {
|
|||
process.env.WAKATIME_API_KEY
|
||||
)
|
||||
return {
|
||||
main: data.categories[0].text,
|
||||
avg: data.human_readable_daily_average_including_other_language,
|
||||
human_readable_daily_average_including_other_language:
|
||||
data.data.human_readable_daily_average_including_other_language,
|
||||
human_readable_total_including_other_language:
|
||||
data.data.human_readable_total_including_other_language,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +35,6 @@ export default class WakatimeService {
|
|||
'https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key=' +
|
||||
process.env.WAKATIME_API_KEY
|
||||
)
|
||||
return data.languages
|
||||
return data.data.languages
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue