Skip to content

Commit ec396a8

Browse files
ARC-036 MVP (#10)
Co-authored-by: israel.aristide <israel.aristide@plusgrade.com>
1 parent fca9990 commit ec396a8

32 files changed

Lines changed: 629 additions & 118 deletions

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.next

.fleet/run.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"configurations": [
3+
4+
{
5+
"name": "dev (1)",
6+
"type": "npm",
7+
"workingDir": "$PROJECT_DIR$",
8+
"command": "run",
9+
"scripts": "dev",
10+
"environment": {
11+
"PORT": "3030"
12+
}
13+
}
14+
]
15+
}

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
FROM node
1+
FROM node:18
22

3-
RUN apt-get update && apt-get install -y npm
43
WORKDIR /app
54

65
COPY ./package*.json .

app/api/auth/route.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { BASE_URI, USE_HTTPS } from "@/lib/definitions";
2+
import {NextRequest, NextResponse} from "next/server";
3+
4+
export async function GET(request: NextRequest) {
5+
6+
const token = request.nextUrl.searchParams.get("token");
7+
const expiry = request.nextUrl.searchParams.get("expiry")?? "100000";
8+
9+
if (!token) {
10+
return NextResponse.json({
11+
status: 500
12+
})
13+
}
14+
15+
const response = NextResponse.redirect(`http${USE_HTTPS? 's' : ''}://${BASE_URI}/login`)
16+
17+
response.cookies.set({
18+
name: "session",
19+
value: token,
20+
maxAge: parseInt(expiry),
21+
httpOnly: true,
22+
sameSite: "strict"
23+
});
24+
25+
return response
26+
27+
}

app/api/revoke/route.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { BASE_URI, USE_HTTPS } from "@/lib/definitions";
2+
import { NextResponse } from "next/server";
3+
4+
export async function GET() {
5+
6+
const response = NextResponse.redirect(`http${USE_HTTPS? 's' : ''}://${BASE_URI}/login`)
7+
8+
response.cookies.set({
9+
name: "session",
10+
value: "",
11+
maxAge: 10,
12+
httpOnly: true,
13+
sameSite: "strict"
14+
});
15+
16+
return response
17+
18+
}

app/dashboard/applications/page.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import {
1010
import {
1111
SidebarTrigger,
1212
} from "@/components/ui/sidebar"
13+
import { ApplicationsList } from "@/components/unity/applications/applications-list"
1314

1415
export default function Page() {
1516
return (
16-
<main>
17+
<div className="h-full">
1718
<header className="flex h-16 shrink-0 items-center gap-2">
1819
<div className="flex items-center gap-2 px-4">
1920
<SidebarTrigger className="-ml-1" />
@@ -33,21 +34,10 @@ import {
3334
</Breadcrumb>
3435
</div>
3536
</header>
36-
<div className="flex flex-1 flex-col gap-4 p-4 pt-0">
37-
<div className="grid auto-rows-min gap-4 md:grid-cols-3">
38-
<div className="aspect-video rounded-xl bg-muted/50" />
39-
<div className="aspect-video rounded-xl bg-muted/50" />
40-
<div className="aspect-video rounded-xl bg-muted/50" />
41-
<div className="aspect-video rounded-xl bg-muted/50" />
42-
<div className="aspect-video rounded-xl bg-muted/50" />
43-
<div className="aspect-video rounded-xl bg-muted/50" />
44-
<div className="aspect-video rounded-xl bg-muted/50" />
45-
<div className="aspect-video rounded-xl bg-muted/50" />
46-
<div className="aspect-video rounded-xl bg-muted/50" />
47-
</div>
48-
<div className="min-h-[100vh] flex-1 rounded-xl bg-muted/50 md:min-h-min" />
49-
</div>
50-
</main>
37+
38+
<ApplicationsList/>
39+
40+
</div>
5141
)
5242
}
5343

app/dashboard/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from "@/components/ui/sidebar"
77
import { cookies } from "next/headers";
88

9+
910
export default async function Layout({
1011
children
1112
}: Readonly<{

app/dashboard/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import {
24
Breadcrumb,
35
BreadcrumbItem,

app/layout.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import localFont from "next/font/local";
33
import "./globals.css";
44
import { SITE_TITLE, SITE_DESCRIPTION_META } from "@/lib/definitions";
55

6+
import { cookies } from "next/headers";
7+
import {Auth} from "@/components/auth";
8+
9+
610
const geistSans = localFont({
711
src: "./fonts/GeistVF.woff",
812
variable: "--font-geist-sans",
@@ -19,16 +23,21 @@ export const metadata: Metadata = {
1923
description: SITE_DESCRIPTION_META,
2024
};
2125

22-
export default function RootLayout({
26+
export default async function RootLayout({
2327
children,
2428
}: Readonly<{
2529
children: React.ReactNode;
2630
}>) {
31+
32+
const cookieStore = await cookies()
33+
const token = cookieStore.get('session')?.value?? "";
34+
2735
return (
2836
<html lang="en">
2937
<body
3038
className={`${geistSans.variable} ${geistMono.variable} dark antialiased w-full h-full`}
3139
>
40+
<Auth token={token} />
3241
{children}
3342
</body>
3443
</html>

app/login/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
"use client"
12

23
import { LoginForm } from "@/components/login-form";
4+
import { useRouter } from "next/navigation";
5+
import { useEffect } from "react";
36

47
export default function Login() {
8+
9+
const { refresh } = useRouter();
10+
11+
useEffect(() => {
12+
refresh();
13+
}, [refresh])
14+
515
return (
616
<div className="flex min-h-svh w-full items-center justify-center p-6 md:p-10">
717
<div className="w-full max-w-sm">

0 commit comments

Comments
 (0)