feat: major rewrite

the application is now rewritten in next.js. this commit also adds the ability to see trailers, did you know, more like this, etc. on title page.

BREAKING CHANGE: the whole application is rewritten from scratch.
This commit is contained in:
zyachel
2022-09-11 19:37:24 +05:30
committed by zyachel
parent 620ddf348a
commit 9891204f5a
129 changed files with 6314 additions and 4671 deletions

View File

@ -0,0 +1,29 @@
// external deps
import * as cheerio from 'cheerio';
// local files
import axiosInstance from '../axiosInstance';
import cleanTitle from '../cleaners/title';
import { AppError } from '../helpers';
// interfaces
import RawTitle from '../../interfaces/misc/rawTitle';
const title = async (titleId: string) => {
try {
// getting data
const res = await axiosInstance(`/title/${titleId}`);
const $ = cheerio.load(res.data);
const rawData = $('script#__NEXT_DATA__').text();
// cleaning it a bit
const parsedRawData: RawTitle = JSON.parse(rawData);
const cleanData = cleanTitle(parsedRawData);
// returning
return cleanData;
} catch (err: any) {
if (err.response?.status === 404)
throw new AppError('not found', 404, err.cause);
throw new AppError('something went wrong', 500, err.cause);
}
};
export default title;