Fixing merge issues.

This commit is contained in:
Bradley Shellnut 2023-02-15 17:04:54 -08:00
parent e9ee47de56
commit 87f8f4ccf9
2 changed files with 10 additions and 27 deletions

View file

@ -26,14 +26,20 @@ export async function fetchArticlesApi(
) {
const pageQuery: PageQuery = {
sort: 'updated',
perPage: +PAGE_SIZE,
perPage: +queryParams?.limit || +PAGE_SIZE,
since: 0,
page: +queryParams?.page || 1,
tags: 'programming',
content: 'metadata'
};
const entriesQueryParams = new URLSearchParams(pageQuery);
const entriesQueryParams = new URLSearchParams({
...pageQuery,
perPage: `${pageQuery.perPage}`,
since: `${pageQuery.since}`,
page: `${pageQuery.page}`
});
console.log(`Entries params: ${entriesQueryParams}`);
if (USE_REDIS_CACHE) {
const cached = await redis.get(entriesQueryParams.toString());
@ -62,29 +68,6 @@ export async function fetchArticlesApi(
const auth = await authResponse.json();
const pageQuery: PageQuery = {
sort: 'updated',
perPage: +queryParams?.limit || +PAGE_SIZE,
since: 0,
page: +queryParams?.page || 1,
tags: 'programming',
content: 'metadata'
};
const entriesQueryParams = new URLSearchParams({
...pageQuery,
perPage: `${pageQuery.perPage}`,
since: `${pageQuery.since}`,
page: `${pageQuery.page}`
});
console.log(`Entries params: ${entriesQueryParams}`);
if (lastFetched) {
pageQuery.since = Math.round(lastFetched / 1000);
}
lastFetched = new Date();
const nbEntries = 0;
const pageResponse = await fetch(`${WALLABAG_URL}/api/entries.json?${entriesQueryParams}`, {
method: 'GET',
headers: {
@ -127,7 +110,7 @@ export async function fetchArticlesApi(
}
});
return {
const responseData = {
articles,
currentPage: page,
totalPages: pages > +WALLABAG_MAX_PAGES ? +WALLABAG_MAX_PAGES : pages,

View file

@ -3,7 +3,7 @@ import { WALLABAG_MAX_PAGES } from '$env/static/private';
import type { RequestHandler, RequestEvent } from './$types';
import { fetchArticlesApi } from '$root/routes/api';
export const GET: RequestHandler = async ({ url }: RequestEvent) => {
export const GET: RequestHandler = async ({ setHeaders, url }: RequestEvent) => {
try {
const page = url?.searchParams?.get('page') || '1';
if (+page > +WALLABAG_MAX_PAGES) {