Skip to content

Commit

Permalink
refactor: put the whole application under /app folder
Browse files Browse the repository at this point in the history
  • Loading branch information
diego3g committed Apr 11, 2024
1 parent 95d2b2f commit b859fd3
Show file tree
Hide file tree
Showing 66 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function ViewsCount() {
return (
<Card className="relative">
<p className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-center text-sm leading-relaxed text-muted-foreground">
<Link href="/settings/organization" className="underline">
<Link href="/app/settings/organization" className="underline">
Setup your Bunny account
</Link>{' '}
to see metrics
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function BatchUploadList({ batchId }: BatchUploadListProps) {
<TableCell>
<div className="flex flex-col">
<Link
href={`/videos/${video.id}`}
href={`/app/videos/${video.id}`}
prefetch={false}
className="font-medium text-primary outline-none hover:underline"
>
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function WebhookLogsFilters() {
}

startTransition(() => {
router.push(`/settings/developers/logs?${params.toString()}`)
router.push(`/app/settings/developers/logs?${params.toString()}`)
})
}

Expand All @@ -58,7 +58,7 @@ export function WebhookLogsFilters() {
params.delete('query')
params.delete('trigger')

router.push(`/settings/developers/logs?${params.toString()}`)
router.push(`/app/settings/developers/logs?${params.toString()}`)
}

const hasFilters = trigger !== undefined || query !== ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export function WebhookLogsList() {
key={webhookLog.id}
className="cursor-pointer"
onClick={() =>
router.push(`/settings/developers/logs/${webhookLog.id}`)
router.push(
`/app/settings/developers/logs/${webhookLog.id}`,
)
}
>
<TableCell className="py-1.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default async function SettingsPage() {

<div className="space-x-3">
<Button size="default" variant="outline" asChild>
<Link href="/settings/developers/logs" prefetch={false}>
<Link href="/app/settings/developers/logs" prefetch={false}>
<Code2 className="mr-2 size-4" />
Webhook logs
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function WebhooksList() {

function navigateToPage(pageIndex: number) {
router.push(
`/settings/developers?${createQueryString('pageIndex', String(pageIndex))}`,
`/app/settings/developers?${createQueryString('pageIndex', String(pageIndex))}`,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export default async function Layout({ children }: { children: ReactNode }) {
<span className="mb-2 px-4 text-xxs font-semibold uppercase text-muted-foreground">
General
</span>
<AsideLink href="/settings/profile">
<AsideLink href="/app/settings/profile">
<User2 className="mr-2 size-4" />
Profile
</AsideLink>
<AsideLink href="/settings/organization">
<AsideLink href="/app/settings/organization">
<Building className="mr-2 size-4" />
Organization
</AsideLink>
Expand All @@ -28,11 +28,11 @@ export default async function Layout({ children }: { children: ReactNode }) {
<span className="mb-2 px-4 text-xxs font-semibold uppercase text-muted-foreground">
Developers
</span>
<AsideLink href="/settings/developers">
<AsideLink href="/app/settings/developers">
<Code2 className="mr-2 size-4" />
API & Webhooks
</AsideLink>
<AsideLink href="/settings/developers/logs">
<AsideLink href="/app/settings/developers/logs">
<SquareDashedBottomCode className="mr-2 size-4" />
Webhook Logs
</AsideLink>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default async function Upload() {
<AlertCircle className="mt-1.5 size-6 shrink-0 text-amber-400" />
<p className="leading-relaxed text-muted-foreground">
Setup your{' '}
<Link href="/settings/organization" className="underline">
<Link href="/app/settings/organization" className="underline">
Bunny account integration
</Link>{' '}
before uploading videos on Nivo.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function UploadList() {
try {
const { batchId } = await createUploadBatch({ files })

router.push(`/batches/${batchId}`)
router.push(`/app/batches/${batchId}`)
} catch {
toast.error('Uh oh! Something went wrong.', {
description:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default async function UploadsPage({
<TableCell>
<div className="flex flex-col">
<Link
href={`/videos/${video.id}`}
href={`/app/videos/${video.id}`}
prefetch={false}
className="font-medium text-primary outline-none hover:underline"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function UploadsFilters() {
tags.forEach((tag) => params.append('tagsFilter', tag))

startTransition(() => {
router.push(`/uploads?${params.toString()}`)
router.push(`/app/uploads?${params.toString()}`)
})
}

Expand All @@ -44,7 +44,7 @@ export function UploadsFilters() {
params.delete('titleFilter')
params.delete('tagsFilter')

router.push(`/uploads?${params.toString()}`)
router.push(`/app/uploads?${params.toString()}`)
}

const hasFilters = title !== '' || tags.length > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ export function UploadsPagination({
)

function navigateToPage(pageIndex: number) {
router.push(`/uploads?${createQueryString('pageIndex', String(pageIndex))}`)
router.push(
`/app/uploads?${createQueryString('pageIndex', String(pageIndex))}`,
)
}

function setPageSize(pageSize: string) {
router.push(`/uploads?${createQueryString('pageSize', pageSize)}`)
router.push(`/app/uploads?${createQueryString('pageSize', pageSize)}`)
}

const page = pageIndex + 1
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions apps/web/src/app/auth/sign-in/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export async function signInWithEmail(data: FormData) {
await signIn('credentials', {
email,
password,
redirectTo: '/dashboard',
redirectTo: '/app',
})
}

export async function signInWithGithub() {
await signIn('google', {
redirectTo: '/dashboard',
redirectTo: '/app',
})
}
6 changes: 3 additions & 3 deletions apps/web/src/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function Header() {
<Separator orientation="vertical" className="h-6" />

<nav className="flex items-center space-x-2 lg:space-x-3">
<MenuLink href="/dashboard">Dashboard</MenuLink>
<MenuLink href="/uploads">Uploads</MenuLink>
<MenuLink href="/app">Dashboard</MenuLink>
<MenuLink href="/app/uploads">Uploads</MenuLink>
</nav>
</div>

Expand All @@ -38,7 +38,7 @@ export function Header() {
<Separator orientation="vertical" className="h-6" />

<Button size="sm" asChild>
<Link href="/upload">
<Link href="/app/upload">
<PlusCircle className="mr-2 size-4" />
Upload video
</Link>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/header/menu-link.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Link from 'next/link'
import { ComponentProps } from 'react'

import { NavLink } from '../nav-link'

export function MenuLink(props: ComponentProps<typeof Link>) {
export function MenuLink(props: ComponentProps<typeof NavLink>) {
return (
<NavLink
shouldMatchExact
className="flex h-14 items-center border-b-2 border-transparent px-3 py-1.5 text-sm font-medium text-muted-foreground transition-colors hover:border-border data-[current=true]:border-teal-400 data-[current=true]:text-accent-foreground"
{...props}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/header/search-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function SearchItem({ video, onRequestClose }: SearchItemProps) {

function handleNavigate() {
startTransition(() => {
router.push(`/videos/${video.id}`)
router.push(`/app/videos/${video.id}`)
})
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/header/user-profile-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export async function UserProfileButton() {
<DropdownMenuContent align="end" className="w-48">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuItem className="flex items-center gap-2" asChild>
<Link href="/settings/profile" className="w-full">
<Link href="/app/settings/profile" className="w-full">
<Cog className="size-4" />
Settings
</Link>
</DropdownMenuItem>
<DropdownMenuItem className="flex items-center gap-2" asChild>
<Link href="/settings/developers" className="w-full">
<Link href="/app/settings/developers" className="w-full">
<Code className="size-4" />
Developers
</Link>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/transcription-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function TranscriptionPreview({ videoId }: TranscriptionPreviewProps) {
autoFocus
/>
<Button variant="secondary" asChild>
<Link href={`/videos/${data?.transcription?.uploadId}`}>
<Link href={`/app/videos/${data?.transcription?.uploadId}`}>
<Edit2 className="mr-2 h-3 w-3" />
Review
</Link>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/upload-item-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function UploadItemActions({ videoId }: UploadItemActionsProps) {
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-[160px]">
<DropdownMenuItem asChild>
<Link href={`/videos/${videoId}`} prefetch={false}>
<Link href={`/app/videos/${videoId}`} prefetch={false}>
<Pencil2Icon className="mr-2 h-4 w-4" />
<span>Edit</span>
</Link>
Expand Down
12 changes: 4 additions & 8 deletions packages/auth/auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,25 @@ export const authConfig = {
authorized({ auth, request: { nextUrl } }) {
const isLoggedIn = !!auth?.user

const isOnPublicPages =
nextUrl.pathname.startsWith('/auth') ||
nextUrl.pathname === '/' ||
nextUrl.pathname === '/about'
const isOnWebhooks = nextUrl.pathname.startsWith('/api/webhooks')
const isOnPublicAPIRoutes = nextUrl.pathname.startsWith('/api/auth')
const isOnAPIRoutes = nextUrl.pathname.startsWith('/api')
const isOnPrivatePages = !isOnPublicPages
const isOnPrivatePages = nextUrl.pathname.startsWith('/app')
const isOnPublicPages = !isOnPrivatePages

if (isOnWebhooks || isOnPublicAPIRoutes) {
return true
}

if (isOnPublicPages && isLoggedIn) {
return Response.redirect(new URL('/dashboard', nextUrl))
if (isOnPublicPages && !isOnAPIRoutes && isLoggedIn) {
return Response.redirect(new URL('/app', nextUrl))
}

if (isOnAPIRoutes && !isLoggedIn) {
return Response.json({ message: 'Unauthorized.' }, { status: 401 })
}

if (isOnPrivatePages && !isLoggedIn) {
// Redirect user back to sign in
return false
}

Expand Down

0 comments on commit b859fd3

Please sign in to comment.