mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-04-10 11:58:41 +00:00
NORY-34: add parseTokens() function after rebase
This commit is contained in:
parent
3d6928a839
commit
4ebd10d699
1 changed files with 20 additions and 1 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { getOAuth2Api } from '@/ory/sdk/server';
|
import { getOAuth2Api } from '@/ory/sdk/server';
|
||||||
import { parseTokens } from '@/app/(inside)/user/page';
|
|
||||||
import { ClientDataTable } from '@/app/(inside)/client/data-table';
|
import { ClientDataTable } from '@/app/(inside)/client/data-table';
|
||||||
|
|
||||||
export interface FetchClientPageProps {
|
export interface FetchClientPageProps {
|
||||||
|
@ -7,6 +6,26 @@ export interface FetchClientPageProps {
|
||||||
pageToken: string;
|
pageToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseTokens(link: string) {
|
||||||
|
|
||||||
|
const parsed = link.split(',').map((it) => {
|
||||||
|
const startRel = it.lastIndexOf('rel="');
|
||||||
|
const endRel = it.lastIndexOf('"');
|
||||||
|
const rel = it.slice(startRel, endRel);
|
||||||
|
|
||||||
|
const startToken = it.lastIndexOf('page_token=');
|
||||||
|
const endToken = it.lastIndexOf('&');
|
||||||
|
const token = it.slice(startToken, endToken);
|
||||||
|
|
||||||
|
return [rel, token];
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Map(parsed.map(obj => [
|
||||||
|
obj[0].replace('rel="', ''),
|
||||||
|
obj[1].replace('page_token=', ''),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchClientPage({ pageSize, pageToken }: FetchClientPageProps) {
|
async function fetchClientPage({ pageSize, pageToken }: FetchClientPageProps) {
|
||||||
'use server';
|
'use server';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue