feat: auth using sse

This commit is contained in:
ner committed 2024-10-17 21:47:55 +03:00
1 parent b72355f7b8
commit df0f7c943b
10 files changed
+1101 -292

No files matched your search

+6 -2
View File
@@ -1,7 +1,11 @@
class Http {
private base = 'https://api.themoviedb.org/3';
get<T>(url: string, { params }: { params?: Record<string, unknown> } = {}, base?: string): Promise<T> {
get<T>(
url: string,
{ params, force }: { params?: Record<string, unknown>; force?: boolean } = {},
base?: string
): Promise<T> {
const serializedParams = Object.entries(params || {}).reduce((params, [key, value]) => {
if (!['', undefined, null].includes(value as string)) {
params.set(key, value as string);
@@ -14,7 +18,7 @@ class Http {
headers: {
Authorization: `Bearer ${process.env.MOVIE_DB_TOKEN}`
},
next: { revalidate: 3600 }
next: force ? undefined : { revalidate: 3600 }
}).then((response) => {
if (!response.ok) return Promise.reject(response);
+3 -1
View File
@@ -9,7 +9,9 @@ import http from './Http';
import { Sort } from './parsers';
export const createRequestToken = async () => {
return http.get<RequestToken>('/authentication/token/new').then(({ request_token }) => request_token);
return http
.get<RequestToken>('/authentication/token/new', { force: true })
.then(({ request_token }) => request_token);
};
export const search = async ({