db and auth packages setup
This commit is contained in:
2
apps/admin/app/api/auth/[...nextauth]/route.ts
Normal file
2
apps/admin/app/api/auth/[...nextauth]/route.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
import { handlers } from "@workspace/auth";
|
||||
export const { GET, POST } = handlers;
|
||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
32
apps/admin/app/page.tsx
Normal file
32
apps/admin/app/page.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import Login from "@/components/login";
|
||||
import Studs from "@/components/studs";
|
||||
import { db, students } from "@workspace/db";
|
||||
import { signIn, signOut } from "@workspace/auth";
|
||||
|
||||
async function getStudents() {
|
||||
"use server";
|
||||
const s = await db.select().from(students);
|
||||
console.log(s);
|
||||
}
|
||||
|
||||
async function logIn() {
|
||||
"use server";
|
||||
await signIn("google");
|
||||
}
|
||||
|
||||
async function logOut() {
|
||||
"use server";
|
||||
await signOut();
|
||||
}
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-svh">
|
||||
<div className="flex flex-col items-center justify-center gap-4">
|
||||
<h1 className="text-2xl font-bold">Hello admins</h1>
|
||||
<Login logIn={logIn} />
|
||||
<Studs action={getStudents} logOut={logOut} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
25
apps/admin/components/login.tsx
Normal file
25
apps/admin/components/login.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
import { signIn } from "@workspace/auth";
|
||||
import { Button } from "@workspace/ui/components/button";
|
||||
|
||||
export default function Login({logIn}: {logIn: () => Promise<void>}) {
|
||||
return (
|
||||
<form action={logIn}>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="outline"
|
||||
className="w-full h-12"
|
||||
>
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-primary/0 via-primary/10 to-primary/0 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-700 ease-out pointer-events-none" />
|
||||
<img
|
||||
src="https://static.cdnlogo.com/logos/g/35/google-icon.svg"
|
||||
alt="Google logo"
|
||||
className="w-5 h-5 transition-transform duration-200"
|
||||
/>
|
||||
<span className="relative z-10 font-medium transition-colors duration-200 group-hover:text-foreground">
|
||||
Sign in with Google
|
||||
</span>
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import * as React from "react"
|
||||
import { ThemeProvider as NextThemesProvider } from "next-themes"
|
||||
import * as React from "react";
|
||||
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
||||
|
||||
export function Providers({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
@@ -9,10 +9,9 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
enableSystem
|
||||
disableTransitionOnChange
|
||||
enableColorScheme
|
||||
>
|
||||
{children}
|
||||
</NextThemesProvider>
|
||||
)
|
||||
);
|
||||
}
|
||||
19
apps/admin/components/studs.tsx
Normal file
19
apps/admin/components/studs.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Button } from "@workspace/ui/components/button";
|
||||
import { auth } from "@workspace/auth";
|
||||
|
||||
export default async function Studs({
|
||||
action,
|
||||
logOut,
|
||||
}: {
|
||||
action: () => void;
|
||||
logOut: () => void;
|
||||
}) {
|
||||
const session = await auth();
|
||||
if (!session?.user) return null;
|
||||
return (
|
||||
<div className="flex gap-2">
|
||||
<Button onClick={action} variant="outline">Click me</Button>
|
||||
<Button onClick={logOut}>Sign Out</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
1
apps/admin/middleware.ts
Normal file
1
apps/admin/middleware.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { auth as middleware } from "@workspace/auth";
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
transpilePackages: ["@workspace/ui"],
|
||||
}
|
||||
};
|
||||
|
||||
export default nextConfig
|
||||
export default nextConfig;
|
||||
@@ -1,20 +1,23 @@
|
||||
{
|
||||
"name": "web",
|
||||
"name": "admin",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"dev": "dotenv -e ../../.env -- next dev --turbopack -p 3001",
|
||||
"build": "dotenv -e ../../.env -- next build",
|
||||
"start": "dotenv -e ../../.env -- next start -p 3001",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@workspace/auth": "workspace:*",
|
||||
"@workspace/db": "workspace:*",
|
||||
"@workspace/ui": "workspace:*",
|
||||
"lucide-react": "^0.475.0",
|
||||
"next": "^15.2.3",
|
||||
"next-auth": "^4.24.11",
|
||||
"next-themes": "^0.4.4",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
@@ -25,6 +28,7 @@
|
||||
"@types/react-dom": "^19",
|
||||
"@workspace/eslint-config": "workspace:^",
|
||||
"@workspace/typescript-config": "workspace:*",
|
||||
"dotenv-cli": "^8.0.0",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
BIN
apps/student/app/favicon.ico
Normal file
BIN
apps/student/app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
30
apps/student/app/layout.tsx
Normal file
30
apps/student/app/layout.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Geist, Geist_Mono } from "next/font/google"
|
||||
|
||||
import "@workspace/ui/globals.css"
|
||||
import { Providers } from "@/components/providers"
|
||||
|
||||
const fontSans = Geist({
|
||||
subsets: ["latin"],
|
||||
variable: "--font-sans",
|
||||
})
|
||||
|
||||
const fontMono = Geist_Mono({
|
||||
subsets: ["latin"],
|
||||
variable: "--font-mono",
|
||||
})
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body
|
||||
className={`${fontSans.variable} ${fontMono.variable} font-sans antialiased `}
|
||||
>
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Button } from "@workspace/ui/components/button"
|
||||
import { Button } from "@workspace/ui/components/button";
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-svh">
|
||||
<div className="flex flex-col items-center justify-center gap-4">
|
||||
<h1 className="text-2xl font-bold">Hello World</h1>
|
||||
<h1 className="text-2xl font-bold">Hello students</h1>
|
||||
<Button size="sm">Button</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
20
apps/student/components.json
Normal file
20
apps/student/components.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "new-york",
|
||||
"rsc": true,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "../../packages/ui/src/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"hooks": "@/hooks",
|
||||
"lib": "@/lib",
|
||||
"utils": "@workspace/ui/lib/utils",
|
||||
"ui": "@workspace/ui/components"
|
||||
}
|
||||
}
|
||||
0
apps/student/components/.gitkeep
Normal file
0
apps/student/components/.gitkeep
Normal file
17
apps/student/components/providers.tsx
Normal file
17
apps/student/components/providers.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
||||
|
||||
export function Providers({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<NextThemesProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
enableSystem
|
||||
enableColorScheme
|
||||
>
|
||||
{children}
|
||||
</NextThemesProvider>
|
||||
);
|
||||
}
|
||||
4
apps/student/eslint.config.js
Normal file
4
apps/student/eslint.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import { nextJsConfig } from "@workspace/eslint-config/next-js"
|
||||
|
||||
/** @type {import("eslint").Linter.Config} */
|
||||
export default nextJsConfig
|
||||
0
apps/student/hooks/.gitkeep
Normal file
0
apps/student/hooks/.gitkeep
Normal file
0
apps/student/lib/.gitkeep
Normal file
0
apps/student/lib/.gitkeep
Normal file
5
apps/student/next-env.d.ts
vendored
Normal file
5
apps/student/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
6
apps/student/next.config.mjs
Normal file
6
apps/student/next.config.mjs
Normal file
@@ -0,0 +1,6 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
transpilePackages: ["@workspace/ui", "@workspace/auth", "@workspace/db"],
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
34
apps/student/package.json
Normal file
34
apps/student/package.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "student",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "dotenv -e ../../.env -- next dev --turbopack -p 3000",
|
||||
"build": "dotenv -e ../../.env -- next build",
|
||||
"start": "dotenv -e ../../.env -- next start -p 3000",
|
||||
"lint": "next lint",
|
||||
"lint:fix": "next lint --fix",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@workspace/ui": "workspace:*",
|
||||
"@workspace/db": "workspace:*",
|
||||
"@workspace/auth": "workspace:*",
|
||||
"lucide-react": "^0.475.0",
|
||||
"next": "^15.2.3",
|
||||
"next-auth": "^4.24.11",
|
||||
"next-themes": "^0.4.4",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@workspace/eslint-config": "workspace:^",
|
||||
"@workspace/typescript-config": "workspace:*",
|
||||
"dotenv-cli": "^8.0.0",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
1
apps/student/postcss.config.mjs
Normal file
1
apps/student/postcss.config.mjs
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from "@workspace/ui/postcss.config";
|
||||
23
apps/student/tsconfig.json
Normal file
23
apps/student/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"extends": "@workspace/typescript-config/nextjs.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./*"],
|
||||
"@workspace/ui/*": ["../../packages/ui/src/*"]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"next.config.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user