feat: add environment configuration and database setup; implement root layout and page components

This commit is contained in:
Wallace Osmar 2025-07-29 13:38:28 -03:00
parent 5ab5cfda9c
commit eebd6a400b
15 changed files with 126 additions and 10 deletions

View File

@ -4,21 +4,24 @@
"type": "module", "type": "module",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev --turbopack", "dev": "pnpm with-env next dev --turbopack",
"build": "next build", "build": "pnpm with-env next build",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "next lint",
"lint:fix": "next lint --fix", "lint:fix": "next lint --fix",
"typecheck": "tsc --noEmit" "typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --"
}, },
"dependencies": { "dependencies": {
"@workspace/ui": "workspace:*", "@t3-oss/env-nextjs": "^0.13.8",
"@workspace/db": "workspace:*", "@workspace/db": "workspace:*",
"@workspace/ui": "workspace:*",
"lucide-react": "^0.475.0", "lucide-react": "^0.475.0",
"next": "^15.2.3", "next": "^15.2.3",
"next-themes": "^0.4.4", "next-themes": "^0.4.4",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0" "react-dom": "^19.0.0",
"zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20", "@types/node": "^20",
@ -26,6 +29,7 @@
"@types/react-dom": "^19", "@types/react-dom": "^19",
"@workspace/eslint-config": "workspace:^", "@workspace/eslint-config": "workspace:^",
"@workspace/typescript-config": "workspace:*", "@workspace/typescript-config": "workspace:*",
"dotenv-cli": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,6 +1,9 @@
import { db } from "@workspace/db"
import { Button } from "@workspace/ui/components/button" import { Button } from "@workspace/ui/components/button"
export default function Page() { export default async function Page() {
const genres = await db.query.Genre.findMany({});
console.log(genres)
return ( return (
<div className="flex items-center justify-center min-h-svh"> <div className="flex items-center justify-center min-h-svh">
<div className="flex flex-col items-center justify-center gap-4"> <div className="flex flex-col items-center justify-center gap-4">

30
apps/web/src/env.ts Normal file
View File

@ -0,0 +1,30 @@
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod/v4";
export const env = createEnv({
/**
* Specify your server-side environment variables schema here.
* This way you can ensure the app isn't built with invalid env vars.
*/
server: {
DATABASE_URL: z.url(),
},
/**
* Specify your client-side environment variables schema here.
* For them to be exposed to the client, prefix them with `NEXT_PUBLIC_`.
*/
client: {
// NEXT_PUBLIC_CLIENTVAR: z.string(),
},
/**
* Destructure all variables from `process.env` to make sure they aren't tree-shaken away.
*/
experimental__runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
// NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR,
},
skipValidation:
!!process.env.CI || process.env.npm_lifecycle_event === "lint",
});

View File

@ -3,8 +3,9 @@
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./*"], "@/*": ["./src/*"],
"@workspace/ui/*": ["../../packages/ui/src/*"] "@workspace/ui/*": ["../../packages/ui/src/*"],
"@workspace/db/*": ["../../packages/db/src/*"]
}, },
"plugins": [ "plugins": [
{ {

15
docker-compose.yaml Normal file
View File

@ -0,0 +1,15 @@
services:
db:
image: postgres:17-alpine
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: webnovelfever
ports:
- 5432:5432
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:

View File

@ -26,7 +26,7 @@
"@types/pg": "^8.15.4", "@types/pg": "^8.15.4",
"@workspace/eslint-config": "workspace:*", "@workspace/eslint-config": "workspace:*",
"@workspace/typescript-config": "workspace:*", "@workspace/typescript-config": "workspace:*",
"dotenv-cli": "^9.0.0", "dotenv-cli": "catalog:",
"drizzle-kit": "^0.31.4", "drizzle-kit": "^0.31.4",
"eslint": "^9.20.1", "eslint": "^9.20.1",
"tsup": "^8.5.0", "tsup": "^8.5.0",

View File

@ -6,6 +6,9 @@ settings:
catalogs: catalogs:
default: default:
dotenv-cli:
specifier: ^9.0.0
version: 9.0.0
typescript: typescript:
specifier: ^5.7.3 specifier: ^5.7.3
version: 5.7.3 version: 5.7.3
@ -35,6 +38,9 @@ importers:
apps/web: apps/web:
dependencies: dependencies:
'@t3-oss/env-nextjs':
specifier: ^0.13.8
version: 0.13.8(typescript@5.7.3)(zod@3.25.76)
'@workspace/db': '@workspace/db':
specifier: workspace:* specifier: workspace:*
version: link:../../packages/db version: link:../../packages/db
@ -56,6 +62,9 @@ importers:
react-dom: react-dom:
specifier: ^19.0.0 specifier: ^19.0.0
version: 19.0.0(react@19.0.0) version: 19.0.0(react@19.0.0)
zod:
specifier: 'catalog:'
version: 3.25.76
devDependencies: devDependencies:
'@types/node': '@types/node':
specifier: ^20 specifier: ^20
@ -72,6 +81,9 @@ importers:
'@workspace/typescript-config': '@workspace/typescript-config':
specifier: workspace:* specifier: workspace:*
version: link:../../packages/typescript-config version: link:../../packages/typescript-config
dotenv-cli:
specifier: 'catalog:'
version: 9.0.0
typescript: typescript:
specifier: 'catalog:' specifier: 'catalog:'
version: 5.7.3 version: 5.7.3
@ -101,7 +113,7 @@ importers:
specifier: workspace:* specifier: workspace:*
version: link:../typescript-config version: link:../typescript-config
dotenv-cli: dotenv-cli:
specifier: ^9.0.0 specifier: 'catalog:'
version: 9.0.0 version: 9.0.0
drizzle-kit: drizzle-kit:
specifier: ^0.31.4 specifier: ^0.31.4
@ -914,6 +926,40 @@ packages:
'@swc/helpers@0.5.15': '@swc/helpers@0.5.15':
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==} resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
'@t3-oss/env-core@0.13.8':
resolution: {integrity: sha512-L1inmpzLQyYu4+Q1DyrXsGJYCXbtXjC4cICw1uAKv0ppYPQv656lhZPU91Qd1VS6SO/bou1/q5ufVzBGbNsUpw==}
peerDependencies:
arktype: ^2.1.0
typescript: '>=5.0.0'
valibot: ^1.0.0-beta.7 || ^1.0.0
zod: ^3.24.0 || ^4.0.0-beta.0
peerDependenciesMeta:
arktype:
optional: true
typescript:
optional: true
valibot:
optional: true
zod:
optional: true
'@t3-oss/env-nextjs@0.13.8':
resolution: {integrity: sha512-QmTLnsdQJ8BiQad2W2nvV6oUpH4oMZMqnFEjhVpzU0h3sI9hn8zb8crjWJ1Amq453mGZs6A4v4ihIeBFDOrLeQ==}
peerDependencies:
arktype: ^2.1.0
typescript: '>=5.0.0'
valibot: ^1.0.0-beta.7 || ^1.0.0
zod: ^3.24.0 || ^4.0.0-beta.0
peerDependenciesMeta:
arktype:
optional: true
typescript:
optional: true
valibot:
optional: true
zod:
optional: true
'@tailwindcss/node@4.0.8': '@tailwindcss/node@4.0.8':
resolution: {integrity: sha512-FKArQpbrbwv08TNT0k7ejYXpF+R8knZFAatNc0acOxbgeqLzwb86r+P3LGOjIeI3Idqe9CVkZrh4GlsJLJKkkw==} resolution: {integrity: sha512-FKArQpbrbwv08TNT0k7ejYXpF+R8knZFAatNc0acOxbgeqLzwb86r+P3LGOjIeI3Idqe9CVkZrh4GlsJLJKkkw==}
@ -3696,6 +3742,18 @@ snapshots:
dependencies: dependencies:
tslib: 2.8.1 tslib: 2.8.1
'@t3-oss/env-core@0.13.8(typescript@5.7.3)(zod@3.25.76)':
optionalDependencies:
typescript: 5.7.3
zod: 3.25.76
'@t3-oss/env-nextjs@0.13.8(typescript@5.7.3)(zod@3.25.76)':
dependencies:
'@t3-oss/env-core': 0.13.8(typescript@5.7.3)(zod@3.25.76)
optionalDependencies:
typescript: 5.7.3
zod: 3.25.76
'@tailwindcss/node@4.0.8': '@tailwindcss/node@4.0.8':
dependencies: dependencies:
enhanced-resolve: 5.18.1 enhanced-resolve: 5.18.1

View File

@ -4,3 +4,4 @@ packages:
catalog: catalog:
typescript: ^5.7.3 typescript: ^5.7.3
zod: ^3.25.1 zod: ^3.25.1
dotenv-cli: ^9.0.0

View File

@ -32,6 +32,10 @@
"studio": { "studio": {
"cache": false, "cache": false,
"persistent": true "persistent": true
},
"push": {
"cache": false,
"persistent": true
} }
} }
} }