Skip to content

Commit

Permalink
Merge branch 'unkeyed:main' into fix/feedback-form-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
unrenamed authored Oct 9, 2024
2 parents 75ac01b + b01d946 commit 026c1f4
Show file tree
Hide file tree
Showing 65 changed files with 305 additions and 217 deletions.
2 changes: 1 addition & 1 deletion apps/billing/src/lib/db-marketing/schemas/searchQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { relations, sql } from "drizzle-orm";
import { relations } from "drizzle-orm";
import {
boolean,
index,
Expand Down
3 changes: 0 additions & 3 deletions apps/billing/src/lib/db-marketing/schemas/serper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { db } from "@/lib/db-marketing/client";
import type * as serper from "@/lib/serper";
import { relations } from "drizzle-orm";
import { eq } from "drizzle-orm";
import { index, int, json, mysqlTable, text, timestamp, varchar } from "drizzle-orm/mysql-core";
import { createSelectSchema } from "drizzle-zod";
import type { z } from "zod";
Expand Down
1 change: 0 additions & 1 deletion apps/billing/src/lib/tinybird.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Tinybird as Client } from "@chronark/zod-bird";
import { newId } from "@unkey/id";
import { z } from "zod";

export class Tinybird {
Expand Down
4 changes: 1 addition & 3 deletions apps/billing/src/trigger/downgrade-requests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { connectDatabase, eq, schema } from "@/lib/db";
import { env } from "@/lib/env";
import { eventTrigger } from "@trigger.dev/sdk";
import { logger, task } from "@trigger.dev/sdk/v3";
import { task } from "@trigger.dev/sdk/v3";

export const downgradeTask = task({
id: "billing_downgrade",
Expand Down
1 change: 0 additions & 1 deletion apps/billing/src/trigger/invoicing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { logger, schedules } from "@trigger.dev/sdk/v3";

import { connectDatabase } from "@/lib/db";

import Stripe from "stripe";
import { createInvoiceTask } from "./create-invoice";
import { downgradeTask } from "./downgrade-requests";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "@/components/ui/breadcrumb";

import { BreadcrumbSkeleton } from "@/components/dashboard/breadcrumb-skeleton";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import { unstable_cache as cache } from "next/cache";
import { Suspense } from "react";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "@/components/ui/breadcrumb";

import { BreadcrumbSkeleton } from "@/components/dashboard/breadcrumb-skeleton";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import { unstable_cache as cache } from "next/cache";
import { Suspense } from "react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
Expand Down
3 changes: 0 additions & 3 deletions apps/dashboard/app/(app)/@breadcrumb/identities/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Badge } from "@/components/ui/badge";
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";

export const dynamic = "force-dynamic";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { toast } from "@/components/ui/toaster";
import { trpc } from "@/lib/trpc/client";
import { cn } from "@/lib/utils";
import { zodResolver } from "@hookform/resolvers/zod";
import type { Key } from "@unkey/db";
import { useRouter } from "next/navigation";
import { useForm } from "react-hook-form";
import { z } from "zod";
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/app/(app)/apis/client.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";
import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder";
import { PageHeader } from "@/components/dashboard/page-header";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
Expand Down
4 changes: 0 additions & 4 deletions apps/dashboard/app/(app)/authorization/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type * as React from "react";

import { Banner } from "@/components/banner";
import { Navbar } from "@/components/dashboard/navbar";
import { PageHeader } from "@/components/dashboard/page-header";
import { OptIn } from "@/components/opt-in";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import Link from "next/link";
import { redirect } from "next/navigation";

export const dynamic = "force-dynamic";
Expand Down
4 changes: 0 additions & 4 deletions apps/dashboard/app/(app)/identities/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import type * as React from "react";

import { Banner } from "@/components/banner";
import { Navbar } from "@/components/dashboard/navbar";
import { PageHeader } from "@/components/dashboard/page-header";
import { OptIn } from "@/components/opt-in";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import Link from "next/link";
import { redirect } from "next/navigation";

export const dynamic = "force-dynamic";
Expand Down
12 changes: 2 additions & 10 deletions apps/dashboard/app/(app)/identities/page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { redirect } from "next/navigation";

import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder";
import {
Table,
TableBody,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import { Loader2, Scan } from "lucide-react";
import { Loader2 } from "lucide-react";
import { unstable_cache as cache } from "next/cache";
import { parseAsInteger, parseAsString } from "nuqs/server";
import { Suspense } from "react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
"use client";
import { Loading } from "@/components/dashboard/loading";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import {
Form,
FormControl,
Expand All @@ -33,7 +24,6 @@ import { trpc } from "@/lib/trpc/client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useRouter } from "next/navigation";
import type React from "react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Button } from "@/components/ui/button";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import { getAllSemanticCacheLogs } from "@/lib/tinybird";
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/app/(app)/semantic-cache/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PageHeader } from "@/components/dashboard/page-header";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import { redirect } from "next/navigation";
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/app/(app)/settings/billing/plans/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { db } from "@/lib/db";
import { ArrowLeft } from "lucide-react";
import Link from "next/link";
import { notFound } from "next/navigation";
import React from "react";
import { ChangePlanButton } from "./button";

const tiers = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"use client";

import { CopyButton } from "@/components/dashboard/copy-button";
import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";
import { toast } from "@/components/ui/toaster";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { trpc } from "@/lib/trpc/client";
import { Loader2 } from "lucide-react";
import { useRouter } from "next/navigation";
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/app/new/keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from "@/components/ui/card";
import { Code } from "@/components/ui/code";
import { Separator } from "@/components/ui/separator";
import { toast } from "@/components/ui/toaster";
import { trpc } from "@/lib/trpc/client";
import { AlertCircle, KeyRound, Lock } from "lucide-react";
import Link from "next/link";
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/app/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { ThemeProvider as NextThemesProvider } from "next-themes";
import type { ThemeProviderProps } from "next-themes/dist/types";
import * as React from "react";

export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/components/dashboard/create-key-button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import React from "react";
import { Button } from "../ui/button";

export const CreateKeyButton = (props: { apiId: string; keyAuthId: string }) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/components/dashboard/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type SVGProps } from "react";
import type { SVGProps } from "react";

export function Loading({
width = 24,
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/lib/trpc/routers/key/updateName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { db, eq, schema } from "@/lib/db";
import { rateLimitedProcedure, ratelimit } from "@/lib/trpc/ratelimitProcedure";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { auth, t } from "../../trpc";
import { auth } from "../../trpc";

export const updateKeyName = rateLimitedProcedure(ratelimit.update)
.use(auth)
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { db, eq, schema } from "@/lib/db";
import { rateLimitedProcedure, ratelimit } from "@/lib/trpc/ratelimitProcedure";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { auth, t } from "../../trpc";

export const updateKeyOwnerId = rateLimitedProcedure(ratelimit.update)
.input(
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/lib/trpc/routers/key/updateRootKeyName.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { insertAuditLogs } from "@/lib/audit";
import { db, eq, schema } from "@/lib/db";
import { env } from "@/lib/env";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { auth, t } from "../../trpc";
Expand Down
1 change: 0 additions & 1 deletion apps/dashboard/lib/trpc/routers/rbac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { rateLimitedProcedure, ratelimit } from "@/lib/trpc/ratelimitProcedure";
import { TRPCError } from "@trpc/server";
import { newId } from "@unkey/id";
import { unkeyPermissionValidation } from "@unkey/rbac";
import { Text } from "@visx/text";
import { z } from "zod";
import type { Context } from "../context";
import { t } from "../trpc";
Expand Down
10 changes: 5 additions & 5 deletions apps/docs/quickstart/ratelimiting/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ duration = amount of time to limit against for example "30s"
**/
const limiter = new Ratelimit({
namespace: "bun-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
namespace: "bun-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
})

const server = Bun.serve({
async fetch(req) {
const identifier = req.getUserId() // or ip or anything else you want

const ratelimit = await unkey.limit(identifier)
const ratelimit = await limiter.limit(identifier)
if (!ratelimit.success){
return Response("try again later", { status: 429 })
}
Expand Down
10 changes: 5 additions & 5 deletions apps/docs/quickstart/ratelimiting/express.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ duration = amount of time to limit against for example "30s"
**/
const limiter = new Ratelimit({
namespace: "express-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
namespace: "express-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
});


Expand All @@ -95,7 +95,7 @@ app.get('/', (req: Request, res: Response) => {
app.get('/secret', async (req: Request, res: Response) => {
const identifier = req.getUserId() // or ip or anything else you want

const ratelimit = await unkey.limit(identifier)
const ratelimit = await limiter.limit(identifier)
if (!ratelimit.success){
res.status(429).send("Please try again later")
}
Expand Down
22 changes: 11 additions & 11 deletions apps/docs/quickstart/ratelimiting/hono.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ Create a new route and add the following code

```ts /src/index.ts
import { Hono } from "hono";
import {Ratelimit } from "@unkey/ratelimit";
import { Ratelimit } from "@unkey/ratelimit";
const app = new Hono();
const limiter = new Ratelimit({
namespace: "hono-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
namespace: "hono-example",
limit: 2,
duration: "30s",
rootKey: process.env.UNKEY_ROOT_KEY
});
app.get("/", (c) => {
const identifier = getUserId(); // or ip or anything else you want
const ratelimit = await unkey.limit(identifier)
const ratelimit = await limiter.limit(identifier)
if (!ratelimit.success){
return c.status(429).text("Please try again later")
}
Expand All @@ -110,12 +110,12 @@ export default app;
<Step title="Running it">
<Tabs>
<Tab title="bun">
<Tab title="npm">
```bash
bun run dev
npm run dev
```
</Tab>
<Tab title="pnpm">
<Tab title="pnpm">
```bash
pnpm run dev
```
Expand All @@ -125,9 +125,9 @@ export default app;
yarn run dev
```
</Tab>
<Tab title="npm">
<Tab title="bun">
```bash
npm run dev
bun run dev
```
</Tab>
</Tabs>
Expand Down
Loading

0 comments on commit 026c1f4

Please sign in to comment.