Skip to content

Commit 631b6f6

Browse files
authored
chore: Upgrade playground to v2 (#107)
* Update to V2 Update this project to V2 Unkey * fix helper
1 parent 7cbdfda commit 631b6f6

File tree

7 files changed

+556
-340
lines changed

7 files changed

+556
-340
lines changed

apps/play/app/page.tsx

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export default function Page() {
187187
},
188188
},
189189
},
190+
190191
"keys.deleteKey": {
191192
method: "POST",
192193
route: "keys.deleteKey",
@@ -622,7 +623,7 @@ export default function Page() {
622623

623624
<div className="mt-2.5">
624625
<code
625-
className="block bg-transparent rounded-md border border-input px-3 py-2 shadow-sm resize-none font-mono min-h-max text-xs lg:text-sm p-3 text-[#686868] overflow-scroll"
626+
className="block bg-transparent rounded-md border border-input px-3 py-2 shadow-sm resize-none font-mono min-h-max text-xs lg:text-sm p-3 text-[#686868] "
626627
dangerouslySetInnerHTML={{
627628
__html:
628629
(previousStep !== undefined
@@ -659,35 +660,27 @@ export default function Page() {
659660
href="https://www.unkey.com/docs/libraries/ts/ratelimit#unkeyratelimit"
660661
target="_blank"
661662
>
662-
rate limiting at the edge
663-
</Link>
664-
,{" "}
665-
<Link
666-
className="underline"
667-
href="https://www.unkey.com/docs/libraries/ts/ratelimit#unkeyratelimit"
668-
target="_blank"
669-
>
670-
custom library integrations
663+
low latency global rate limiting
671664
</Link>
672665
,{" "}
673666
<Link
674667
className="underline"
675-
href="https://www.unkey.com/docs/libraries/ts/sdk/overview"
668+
href="https://www.unkey.com/docs/libraries/ts/api"
676669
target="_blank"
677670
>
678671
a TypeScript SDK
679672
</Link>
680673
,{" "}
681674
<Link
682675
className="underline"
683-
href="https://www.unkey.com/docs/libraries/go/overview"
676+
href="https://www.unkey.com/docs/libraries/go/api"
684677
target="_blank"
685678
>
686679
a Golang SDK
687680
</Link>
688681
,{" "}
689682
<Link className="underline" href="https://www.unkey.com/pricing" target="_blank">
690-
a free tier to boost your start
683+
a free tier to get you started
691684
</Link>{" "}
692685
and{" "}
693686
<Link
@@ -796,10 +789,6 @@ export default function Page() {
796789
);
797790
}
798791

799-
// function Container({ className, ...props }: React.HTMLProps<HTMLDivElement>) {
800-
// return <div className="w-full max-w-[640px]" {...props} />;
801-
// }
802-
803792
function SVGLogoUnkey() {
804793
return (
805794
<svg width="59" height="18" viewBox="0 0 59 18" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -824,14 +813,3 @@ const Code = React.forwardRef<HTMLSpanElement, React.HTMLProps<HTMLElement>>(
824813
);
825814
},
826815
);
827-
828-
// const Heading = React.forwardRef<HTMLDivElement, React.HTMLProps<HTMLElement>>(
829-
// ({ children, className, ...props }, ref) => {
830-
// return (
831-
// <strong ref={ref} className={cn("text-lg lg:text-xl block mb-1", className)} {...props}>
832-
// {children}
833-
// <br />
834-
// </strong>
835-
// );
836-
// },
837-
// );

apps/play/lib/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function getStepsData() {
165165
},
166166
];
167167
const step8CurlCommand = `curl --request GET
168-
--url https://api.unkey.dev/v1/keys.getVerifications?keyId=<keyId>
168+
--url https://api.unkey.dev/v2/keys.getVerifications?keyId=<keyId>
169169
--header 'Authorization: Bearer <token>'`;
170170
steps.push({
171171
header: step8Header,

apps/play/lib/helper.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
CreateKeyCommand,
55
DeleteKeyCommand,
66
GetKeyCommand,
7-
GetVerificationsCommand,
87
UpdateKeyCommand,
98
VerifyKeyCommand,
109
} from "./unkey";
@@ -36,7 +35,7 @@ export async function getDataFromString(curlString: string) {
3635
case urls.getkey:
3736
return await GetKeyCommand(params?.keyId ?? "");
3837
case urls.verifyKey:
39-
return await VerifyKeyCommand(data.key, data.apiId);
38+
return await VerifyKeyCommand(data.key);
4039
case urls.updateKey:
4140
return await UpdateKeyCommand(
4241
data.keyId ?? undefined,
@@ -45,8 +44,6 @@ export async function getDataFromString(curlString: string) {
4544
data.expires ? Number.parseInt(data.expires) : undefined,
4645
data.enabled ?? undefined,
4746
);
48-
case urls.getVerifications:
49-
return await GetVerificationsCommand(params?.keyId ?? "");
5047
case urls.deleteKey:
5148
return await DeleteKeyCommand(data.keyId);
5249
default:

apps/play/lib/unkey.ts

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@ export async function CreateKeyCommand(apiId: string) {
88
return { error: "Root Key Not Found" };
99
}
1010
const unkey = new Unkey({ rootKey: rootKey });
11-
const { result, error } = await unkey.keys.create({
11+
const { data, meta } = await unkey.keys.createKey({
1212
apiId: apiId,
1313
byteLength: 16,
1414
enabled: true,
1515
});
16-
const response = { result, error };
16+
const response = { data, meta };
1717

1818
return response;
1919
}
2020

2121
//Verify Key
22-
export async function VerifyKeyCommand(key: string, apiId: string) {
22+
export async function VerifyKeyCommand(key: string) {
2323
if (!rootKey) {
2424
return { error: "Root Key Not Found" };
2525
}
2626
const unkey = new Unkey({ rootKey: rootKey });
27-
const { result, error } = await unkey.keys.verify({
28-
apiId: apiId,
27+
const { data, meta } = await unkey.keys.verifyKey({
2928
key: key,
3029
});
31-
const response = { result, error };
30+
const response = { data, meta };
3231

3332
return response;
3433
}
@@ -38,16 +37,18 @@ export async function GetKeyCommand(keyId: string) {
3837
return { error: "Root Key Not Found" };
3938
}
4039
const unkey = new Unkey({ rootKey: rootKey });
41-
const { result, error } = await unkey.keys.get({ keyId: keyId });
42-
const response = { result, error };
40+
const { data, meta } = await unkey.keys.getKey({
41+
keyId: keyId,
42+
});
43+
const response = { data, meta };
4344

4445
return response;
4546
}
4647

4748
// Update Key
4849
export async function UpdateKeyCommand(
4950
keyId: string,
50-
ownerId: string | undefined,
51+
externalId: string | undefined,
5152
metaData: Record<string, string> | undefined,
5253
expires: number | undefined,
5354
enabled: boolean | undefined,
@@ -56,27 +57,15 @@ export async function UpdateKeyCommand(
5657
return { error: "Root Key Not Found" };
5758
}
5859
const unkey = new Unkey({ rootKey: rootKey });
59-
const { result, error } = await unkey.keys.update({
60+
const { data, meta } = await unkey.keys.updateKey({
6061
keyId: keyId,
61-
ownerId: ownerId ?? undefined,
62+
externalId: externalId ?? undefined,
6263
meta: metaData ?? undefined,
6364
expires: expires ?? undefined,
6465
enabled: enabled ?? undefined,
6566
});
6667

67-
const response = { result, error };
68-
69-
return response;
70-
}
71-
72-
// Get Verifications
73-
export async function GetVerificationsCommand(keyId: string) {
74-
if (!rootKey) {
75-
return { error: "Root Key Not Found" };
76-
}
77-
const unkey = new Unkey({ rootKey: rootKey });
78-
const { result, error } = await unkey.keys.getVerifications({ keyId: keyId });
79-
const response = { result, error };
68+
const response = { data, meta };
8069

8170
return response;
8271
}
@@ -86,8 +75,10 @@ export async function DeleteKeyCommand(keyId: string) {
8675
return { error: "Root Key Not Found" };
8776
}
8877
const unkey = new Unkey({ rootKey: rootKey });
89-
const { result, error } = await unkey.keys.delete({ keyId: keyId });
90-
const response = { result, error };
78+
const { data, meta } = await unkey.keys.deleteKey({
79+
keyId: keyId,
80+
});
81+
const response = { data, meta };
9182

9283
return response;
9384
}

apps/play/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@radix-ui/react-slot": "^1.1.0",
1919
"@radix-ui/react-tabs": "^1.1.0",
2020
"@radix-ui/react-toast": "^1.2.1",
21-
"@unkey/api": "^0.19.5",
21+
"@unkey/api": "^2.1.4",
2222
"@vercel/analytics": "^1.5.0",
2323
"@xterm/xterm": "^5.5.0",
2424
"class-variance-authority": "^0.7.0",

0 commit comments

Comments
 (0)