mirror of
https://github.com/BradNut/personal-website-sveltekit
synced 2025-09-08 23:20:18 +00:00
Fixing merge issues.
This commit is contained in:
parent
e9ee47de56
commit
87f8f4ccf9
2 changed files with 10 additions and 27 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue