[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESlint and Conform Apps & Packages #589

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7534bba
use RSCs in @dub/ui
versecafe Jan 19, 2024
e3d5016
remove accidental temp comment from readme
versecafe Jan 19, 2024
9dd7fed
final UI component that can be moved
versecafe Jan 20, 2024
c6aa72f
clean unused code and document change
versecafe Jan 20, 2024
7ce96c1
typo cleanup
versecafe Jan 20, 2024
16a75db
Merge branch 'dubinc:main' into use-rscs-in-ui-package
versecafe Jan 20, 2024
469bf4f
eslitn package + configs set up
versecafe Jan 29, 2024
698d09a
partial packages eslint conformance
versecafe Jan 29, 2024
dffc46c
Merge branch 'main' into eslint
versecafe Jan 29, 2024
71725e5
Merge branch 'main' into pr/572
steven-tey Jan 30, 2024
fc51c6b
Merge branch 'use-rscs-in-ui-package' of https://github.com/versecafe…
steven-tey Jan 30, 2024
bcadf64
Update pnpm-lock.yaml
steven-tey Jan 30, 2024
e825fe8
small fixes
steven-tey Jan 30, 2024
cfe62fb
Merge branch 'main' into eslint
versecafe Feb 4, 2024
d19b356
fix lockfile
versecafe Feb 4, 2024
a053826
turbo.json fix caching behaviour for env var update, and fix minor er…
versecafe Feb 4, 2024
f33ee0a
Merge branch 'dubinc:main' into use-rscs-in-ui-package
versecafe Feb 4, 2024
5a6c03a
Merge branch 'temp-test' into eslint
versecafe Feb 4, 2024
be1f9a2
Revert "Merge branch 'temp-test' into eslint"
versecafe Feb 4, 2024
405c271
fix pnpm lock
versecafe Feb 5, 2024
3eccb0a
further compliance ui from 82 to 57 problems
versecafe Feb 5, 2024
e78d84f
minor cleaning
versecafe Feb 5, 2024
8b13f90
clean web to bring conformance up
versecafe Feb 5, 2024
b5b77a9
Merge branch 'main' into eslint
versecafe Feb 5, 2024
6768190
fix up lockfile
versecafe Feb 5, 2024
63246e6
Merge branch 'main' into eslint
versecafe Feb 6, 2024
141d4fb
Merge branch 'main' into eslint
versecafe Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clean web to bring conformance up
  • Loading branch information
versecafe committed Feb 5, 2024
commit 8b13f9005a59558482f563dc17e5eb3e18ca0d59
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ Dub.co is the open-source link management infrastructure for modern marketing te
## Tech Stack

- [Next.js](https://nextjs.org/) – framework
- [TypeScript](https://www.typescriptlang.org/) – language
- [Tailwind](https://tailwindcss.com/) – CSS
- [Upstash](https://upstash.com/) – redis
- [Tinybird](https://tinybird.com/) – analytics
- [PlanetScale](https://planetscale.com/) – database
- [TypeScript](https://www.typescriptlang.org/) – language
- [Tailwind](https://tailwindcss.com/) – CSS
- [Upstash](https://upstash.com/) – redis
- [Tinybird](https://tinybird.com/) – analytics
- [PlanetScale](https://planetscale.com/) – database
- [NextAuth.js](https://next-auth.js.org/) – auth
- [BoxyHQ](https://boxyhq.com/enterprise-sso) – SSO/SAML
- [Turborepo](https://turbo.build/repo) – monorepo
- [Stripe](https://stripe.com/) – payments
- [Stripe](https://stripe.com/) – payments
- [Resend](https://resend.com/) – emails
- [Vercel](https://vercel.com/) – deployments

Expand All @@ -71,7 +71,7 @@ We love our contributors! Here's how you can contribute:

## Repo Activity

![Dub.co repo activity – generated by Axiom](https://repobeats.axiom.co/api/embed/c90805656bae44a62c62b38222270d5f697fcfb1.svg "Repobeats analytics image")
![Dub.co repo activity – generated by Axiom](https://repobeats.axiom.co/api/embed/c90805656bae44a62c62b38222270d5f697fcfb1.svg "Repobeats analytics image")

## License

Expand Down
10 changes: 5 additions & 5 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ NEXT_PUBLIC_APP_NAME=Dub.co
NEXT_PUBLIC_APP_DOMAIN=dub.co
NEXT_PUBLIC_APP_SHORT_DOMAIN=dub.sh

# Tinybird – required for analytics
# Tinybird – required for analytics
# Get your Tinybird Auth Token here: https://www.tinybird.co/docs/concepts/auth-tokens.html
TINYBIRD_API_KEY=

# Vercel's Domains API – required for adding and removing domains
# Vercel's Domains API – required for adding and removing domains
# Learn how to set this up: https://vercel.com/templates/next.js/domains-api
PROJECT_ID_VERCEL=
TEAM_ID_VERCEL=
Expand All @@ -21,7 +21,7 @@ AUTH_BEARER_TOKEN=
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=

# Upstash QStash – required for queues and background jobs
# Upstash QStash – required for queues and background jobs
# Get your QStash Token here: https://upstash.com/docs/qstash/overall/getstarted
QSTASH_TOKEN=
QSTASH_CURRENT_SIGNING_KEY=
Expand All @@ -43,7 +43,7 @@ RESEND_API_KEY=
###### OPTIONAL ENV VARS ######
###############################

# Stripe – used for subscriptions
# Stripe – used for subscriptions
# If you don't need this, you can also remove the `lib/stripe` folder and all instances of `stripe` from the codebase
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
STRIPE_SECRET_KEY=
Expand All @@ -59,7 +59,7 @@ GOOGLE_CLIENT_SECRET=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

# Edge Config – used for admin features like banning users, rate limiting etc.
# Edge Config – used for admin features like banning users, rate limiting etc.
# Create one here: https://vercel.com/docs/storage/edge-config
# Alternatively, if you don't need this, you can also remove `lib/edge-config.ts`
# and all instances of `EDGE_CONFIG` and `EDGE_CONFIG_ID` from the codebase
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/admin.dub.co/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { deleteProject } from "@/lib/api/projects";
import { getSession, hashToken } from "@/lib/auth";
import prisma from "@/lib/prisma";
import { DUB_DOMAINS, DUB_PROJECT_ID, getDomainWithoutWWW } from "@dub/utils";
import { DUB_DOMAINS, DUB_PROJECT_ID } from "@dub/utils";
import { randomBytes } from "crypto";
import cloudinary from "cloudinary";
import { get } from "@vercel/edge-config";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/admin.dub.co/components/user-info.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { Badge, Copy, Tick } from "@dub/ui";
import { capitalize, cn, nFormatter } from "@dub/utils";
import { capitalize, nFormatter } from "@dub/utils";
import { useState } from "react";
import { toast } from "sonner";
import { Globe } from "lucide-react";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/admin/links/[linkId]/ban/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { formatRedisLink, redis } from "@/lib/upstash";
import { get } from "@vercel/edge-config";

// DELETE /api/admin/links/[linkId]/ban – ban a link
// DELETE /api/admin/links/[linkId]/ban – ban a link
export const DELETE = withAdmin(async ({ params }) => {
const { linkId } = params as { linkId: string };

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/admin/links/count/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { DUB_DOMAINS, LEGAL_USER_ID } from "@dub/utils";

// GET /api/links – get all user links
// GET /api/links – get all user links
export const GET = withAdmin(async ({ searchParams }) => {
let { groupBy, search, domain, tagId } = searchParams as {
groupBy?: "domain" | "tagId";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/admin/links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { DUB_DOMAINS, LEGAL_USER_ID } from "@dub/utils";

// GET /api/links – get all user links
// GET /api/links – get all user links
export const GET = withAdmin(async ({ searchParams }) => {
const {
domain,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/callback/stripe/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const relevantEvents = new Set([
"customer.subscription.deleted",
]);

// POST /api/callback/stripe – listen to Stripe webhooks
// POST /api/callback/stripe – listen to Stripe webhooks
export const POST = async (req: Request) => {
const buf = await req.text();
const sig = req.headers.get("Stripe-Signature") as string;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/domains/[domain]/exists/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withSession } from "@/lib/auth";
import { domainExists } from "@/lib/api/domains";
import { NextResponse } from "next/server";

// GET /api/domains/[domain]/exists – check if a domain exists
// GET /api/domains/[domain]/exists – check if a domain exists
export const GET = withSession(async ({ params }) => {
const { domain } = params;

Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/api/links/[linkId]/archive/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { archiveLink } from "@/lib/api/links";
import { withAuth } from "@/lib/auth";
import { NextResponse } from "next/server";

// POST /api/links/[linkId]/archive – archive a link
// POST /api/links/[linkId]/archive – archive a link
export const POST = withAuth(async ({ headers, link }) => {
const response = await archiveLink(link!.domain, link!.key, true);
return NextResponse.json(response, { headers });
});

// DELETE /api/links/[linkId]/archive – unarchive a link
// DELETE /api/links/[linkId]/archive – unarchive a link
export const DELETE = withAuth(async ({ headers, link }) => {
const response = await archiveLink(link!.domain, link!.key, false);
return NextResponse.json(response, { headers });
Expand Down
6 changes: 3 additions & 3 deletions apps/web/app/api/links/[linkId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { NextResponse } from "next/server";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
import { qstash } from "@/lib/cron";

// GET /api/links/[linkId] – get a link
// GET /api/links/[linkId] – get a link
export const GET = withAuth(async ({ headers, link }) => {
// link is guaranteed to exist because if not we will return 404
return NextResponse.json(link!, {
headers,
});
});

// PUT /api/links/[linkId] – update a link
// PUT /api/links/[linkId] – update a link
export const PUT = withAuth(async ({ req, headers, project, link }) => {
let body;
try {
Expand Down Expand Up @@ -81,7 +81,7 @@ export const PUT = withAuth(async ({ req, headers, project, link }) => {
});
});

// DELETE /api/links/[linkId] – delete a link
// DELETE /api/links/[linkId] – delete a link
export const DELETE = withAuth(async ({ headers, link, project }) => {
// link is guaranteed to exist because if not we will return 404
const response = await deleteLink({
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/links/bulk/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withAuth } from "@/lib/auth";
import { NextResponse } from "next/server";
import { exceededLimitError } from "@/lib/api/errors";

// POST /api/links/bulk – bulk create up to 100 links
// POST /api/links/bulk – bulk create up to 100 links
export const POST = withAuth(
async ({ req, headers, session, project }) => {
if (!project) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/links/count/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getLinksCount } from "@/lib/api/links";
import { withAuth } from "@/lib/auth";
import { NextResponse } from "next/server";

// GET /api/links/count – get the number of links for a project
// GET /api/links/count – get the number of links for a project
export const GET = withAuth(async ({ headers, searchParams, project }) => {
const { userId } = searchParams;
const count = await getLinksCount({
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/links/exists/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withAuth } from "@/lib/auth";
import { checkIfKeyExists } from "@/lib/api/links";
import { NextResponse } from "next/server";

// GET /api//links/exists – check if a link exists
// GET /api//links/exists – check if a link exists
export const GET = withAuth(
async ({ headers, searchParams }) => {
const { domain, key } = searchParams;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/links/info/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import prisma from "@/lib/prisma";
import { linkConstructor } from "@dub/utils";
import { NextResponse } from "next/server";

// GET /api/links/info – get the info for a link
// GET /api/links/info – get the info for a link
export const GET = withAuth(async ({ headers, searchParams }) => {
const { domain, key } = searchParams;
if (!domain || !key) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/links/random/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withAuth } from "@/lib/auth";
import { getRandomKey } from "@/lib/api/links";
import { NextResponse } from "next/server";

// GET /api/links/random – get a random available link key
// GET /api/links/random – get a random available link key
export const GET = withAuth(async ({ headers, searchParams }) => {
const { domain } = searchParams;
if (!domain) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/api/links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ratelimit } from "@/lib/upstash";
import { APP_DOMAIN_WITH_NGROK, LOCALHOST_IP } from "@dub/utils";
import { NextResponse } from "next/server";

// GET /api/links – get all user links
// GET /api/links – get all user links
export const GET = withAuth(async ({ headers, searchParams, project }) => {
const { domain, tagId, search, sort, page, userId, showArchived } =
searchParams as {
Expand All @@ -32,7 +32,7 @@ export const GET = withAuth(async ({ headers, searchParams, project }) => {
});
});

// POST /api/links – create a new link
// POST /api/links – create a new link
export const POST = withAuth(
async ({ req, headers, session, project }) => {
let body;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/links/sync/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LinkProps, SimpleLinkProps } from "@/lib/types";
import { exceededLimitError } from "@/lib/api/errors";
import { bulkCreateLinks } from "@/lib/api/links";

// POST /api/links/sync – sync user's publicly created links to their accounts
// POST /api/links/sync – sync user's publicly created links to their accounts
export const POST = withAuth(async ({ req, session, project }) => {
let links: SimpleLinkProps[] = [];
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withAuth } from "@/lib/auth";
import { domainExists } from "@/lib/api/domains";
import { NextResponse } from "next/server";

// GET /api/projects/[slug]/domains/[domain]/exists – check if a domain exists
// GET /api/projects/[slug]/domains/[domain]/exists – check if a domain exists
export const GET = withAuth(async ({ domain, project }) => {
const exists = await domainExists(domain);
if (exists) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/api/projects/[slug]/domains/[domain]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { NextResponse } from "next/server";
import { DUB_PROJECT_ID, isDubDomain } from "@dub/utils";

// GET /api/projects/[slug]/domains/[domain] – get a project's domain
// GET /api/projects/[slug]/domains/[domain] – get a project's domain
export const GET = withAuth(async ({ domain, project }) => {
if (isDubDomain(domain) && project.id !== DUB_PROJECT_ID) {
return new Response("Domain does not belong to project.", {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const GET = withAuth(async ({ domain, project }) => {
});
});

// PUT /api/projects/[slug]/domains/[domain] – edit a project's domain
// PUT /api/projects/[slug]/domains/[domain] – edit a project's domain
export const PUT = withAuth(async ({ req, project, domain }) => {
const {
slug: newDomain,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/projects/[slug]/domains/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@/lib/api/domains";
import { exceededLimitError } from "@/lib/api/errors";

// GET /api/projects/[slug]/domains – get all domains for a project
// GET /api/projects/[slug]/domains – get all domains for a project
export const GET = withAuth(async ({ project }) => {
const domains = await prisma.domain.findMany({
where: {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/projects/[slug]/exists/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import prisma from "@/lib/prisma";
import { DEFAULT_REDIRECTS } from "@dub/utils";
import { NextResponse } from "next/server";

// GET /api/projects/[slug]/exists – check if a project exists
// GET /api/projects/[slug]/exists – check if a project exists
export const GET = withSession(async ({ params }) => {
const { slug } = params;
if ((await isReservedKey(slug)) || DEFAULT_REDIRECTS[slug]) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/projects/[slug]/invites/accept/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withSession } from "@/lib/auth";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";

// POST /api/projects/[slug]/invites/accept – accept a project invite
// POST /api/projects/[slug]/invites/accept – accept a project invite
export const POST = withSession(async ({ session, params }) => {
const invite = await prisma.projectInvite.findFirst({
where: {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/api/projects/[slug]/invites/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { inviteUser } from "@/lib/api/users";
import prisma from "@/lib/prisma";
import { exceededLimitError } from "@/lib/api/errors";

// GET /api/projects/[slug]/invites – get invites for a specific project
// GET /api/projects/[slug]/invites – get invites for a specific project
export const GET = withAuth(async ({ project }) => {
const invites = await prisma.projectInvite.findMany({
where: {
Expand Down Expand Up @@ -77,7 +77,7 @@ export const POST = withAuth(
},
);

// DELETE /api/projects/[slug]/invites – delete a pending invite
// DELETE /api/projects/[slug]/invites – delete a pending invite
export const DELETE = withAuth(
async ({ searchParams, project }) => {
const { email } = searchParams;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/projects/[slug]/logo/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import prisma from "@/lib/prisma";
import cloudinary from "cloudinary";
import { NextResponse } from "next/server";

// POST /api/projects/[slug]/logo – upload a new project logo
// POST /api/projects/[slug]/logo – upload a new project logo
export const POST = withAuth(
async ({ req, project }) => {
const { image } = await req.json();
Expand Down
6 changes: 3 additions & 3 deletions apps/web/app/api/projects/[slug]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { deleteProject } from "@/lib/api/projects";
import { DEFAULT_REDIRECTS, validSlugRegex } from "@dub/utils";
import { isReservedKey } from "@/lib/edge-config";

// GET /api/projects/[slug] – get a specific project
// GET /api/projects/[slug] – get a specific project
export const GET = withAuth(async ({ project, headers }) => {
return NextResponse.json(project, { headers });
});

// PUT /api/projects/[slug] – update a specific project
// PUT /api/projects/[slug] – update a specific project
export const PUT = withAuth(
async ({ req, project }) => {
const { name, slug, defaultDomains } = await req.json();
Expand Down Expand Up @@ -62,7 +62,7 @@ export const PUT = withAuth(
},
);

// DELETE /api/projects/[slug] – delete a specific project
// DELETE /api/projects/[slug] – delete a specific project
export const DELETE = withAuth(
async ({ project }) => {
const response = await deleteProject(project);
Expand Down
6 changes: 3 additions & 3 deletions apps/web/app/api/projects/[slug]/saml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextResponse } from "next/server";
import jackson, { samlAudience } from "@/lib/jackson";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";

// GET /api/projects/[slug]/saml – get SAML connections for a specific project
// GET /api/projects/[slug]/saml – get SAML connections for a specific project
export const GET = withAuth(async ({ project }) => {
const { apiController } = await jackson();

Expand All @@ -24,7 +24,7 @@ export const GET = withAuth(async ({ project }) => {
return NextResponse.json(response);
});

// POST /api/projects/[slug]/saml – create a new SAML connection
// POST /api/projects/[slug]/saml – create a new SAML connection
export const POST = withAuth(
async ({ req, project }) => {
const { metadataUrl, encodedRawMetadata } = await req.json();
Expand Down Expand Up @@ -52,7 +52,7 @@ export const POST = withAuth(
},
);

// DELETE /api/projects/[slug]/saml – delete all SAML connections
// DELETE /api/projects/[slug]/saml – delete all SAML connections

export const DELETE = withAuth(
async ({ searchParams }) => {
Expand Down
Loading