Added Mastodon API for Portfolio

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2023-01-19 10:04:52 +05:30
parent 5e4a76a0df
commit 060ec25fcc
Signed by: bravo68web
GPG Key ID: F5671FD7BCB9917A
3 changed files with 43 additions and 0 deletions

View File

@ -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))
}
}

View File

@ -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

View File

@ -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
}
}