Added Mastodon API for Portfolio
This commit is contained in:
parent
5e4a76a0df
commit
060ec25fcc
|
@ -0,0 +1,15 @@
|
|||
import { makeResponse } from '../libs'
|
||||
import MastodonService from '../services/mastodon.service'
|
||||
import { Request, Response } from 'express'
|
||||
|
||||
export default class MastodonController extends MastodonService {
|
||||
public fetchMastodonProfile = async (req: Request, res: Response) => {
|
||||
const data = await this.getMastodonProfile()
|
||||
return res.send(makeResponse(data))
|
||||
}
|
||||
|
||||
public fetchMastodonStatuses = async (req: Request, res: Response) => {
|
||||
const data = await this.getMastodonStatuses()
|
||||
return res.send(makeResponse(data))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { Router } from 'express'
|
||||
import MastodonController from '../../controllers/mastodon.controller'
|
||||
|
||||
const { fetchMastodonProfile, fetchMastodonStatuses } = new MastodonController()
|
||||
|
||||
const router = Router()
|
||||
|
||||
router.get('/profile', fetchMastodonProfile)
|
||||
router.get('/statuses', fetchMastodonStatuses)
|
||||
|
||||
export default router
|
|
@ -0,0 +1,17 @@
|
|||
import axiosInstance from '../helpers/axios_client'
|
||||
|
||||
export default class MastodonService {
|
||||
public getMastodonProfile = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
'https://fosstodon.org/api/v1/accounts/109612266657666903'
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
public getMastodonStatuses = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
'https://fosstodon.org/api/v1/accounts/109612266657666903/statuses'
|
||||
)
|
||||
return data
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue