52 Commits

Author SHA1 Message Date
0d0ba9d5f1 chore(deps): update actions/setup-node action to v5
All checks were successful
Lint / Lint and Check (pull_request) Successful in 27s
Lint / Lint and Check (push) Successful in 26s
2025-09-06 00:04:33 +00:00
a8c78d6a42 fix(deps): update dependency @tanstack/react-query to v5.85.6
All checks were successful
Lint / Lint and Check (push) Successful in 32s
2025-08-30 14:01:56 +00:00
114cba348a fix(deps): update dependency lucide-react to ^0.542.0
All checks were successful
Lint / Lint and Check (push) Successful in 32s
2025-08-30 06:02:03 +00:00
501a784da9 chore(deps): update typescript-eslint monorepo to v8.41.0
All checks were successful
Lint / Lint and Check (push) Successful in 34s
2025-08-30 05:02:37 +00:00
6552451f39 chore(deps): update dependency @types/node to v22.18.0
All checks were successful
Lint / Lint and Check (push) Successful in 26s
2025-08-30 04:03:13 +00:00
8deb7d13e9 fix(deps): update nextjs monorepo to v15.5.2
All checks were successful
Lint / Lint and Check (push) Successful in 28s
2025-08-30 03:04:08 +00:00
2de8e45e92 fix(deps): update dependency postcss-preset-env to v10.3.1
All checks were successful
Lint / Lint and Check (push) Successful in 30s
2025-08-30 02:04:38 +00:00
18d6cf77e5 fix(deps): update dependency drizzle-orm to v0.44.5
All checks were successful
Lint / Lint and Check (push) Successful in 30s
2025-08-30 01:05:32 +00:00
30b28a7cb6 chore(deps): update react monorepo
All checks were successful
Lint / Lint and Check (push) Successful in 30s
2025-08-30 00:04:12 +00:00
e6b4bae90d fix(deps): update nextjs monorepo to v15.5.0
All checks were successful
Lint / Lint and Check (push) Successful in 29s
2025-08-23 08:02:59 +00:00
295c884804 fix(deps): update dependency postcss-preset-env to v10.3.0
All checks were successful
Lint / Lint and Check (push) Successful in 29s
2025-08-23 07:02:48 +00:00
270b21dbf0 fix(deps): update dependency lucide-react to ^0.541.0
All checks were successful
Lint / Lint and Check (push) Successful in 28s
2025-08-23 06:03:27 +00:00
91cd975e51 chore(deps): update typescript-eslint monorepo to v8.40.0
All checks were successful
Lint / Lint and Check (push) Successful in 29s
2025-08-23 05:03:20 +00:00
bedf8f7eab chore(deps): update pnpm to v10.15.0
All checks were successful
Lint / Lint and Check (push) Successful in 28s
2025-08-23 04:03:54 +00:00
b24096ff80 chore(deps): update eslint monorepo to v9.34.0
All checks were successful
Lint / Lint and Check (push) Successful in 29s
2025-08-23 03:04:10 +00:00
7e9754bca4 fix(deps): update dependency cssnano to v7.1.1
All checks were successful
Lint / Lint and Check (push) Successful in 28s
2025-08-23 02:04:50 +00:00
d1495d29e9 fix(deps): update dependency @tanstack/react-query to v5.85.5
All checks were successful
Lint / Lint and Check (push) Successful in 28s
2025-08-23 01:05:52 +00:00
c69b164c23 chore(deps): update dependency @types/react to v19.1.11
All checks were successful
Lint / Lint and Check (push) Successful in 49s
2025-08-23 00:04:25 +00:00
26443ef169 fix(deps): update dependency @tanstack/react-query to v5.85.3
All checks were successful
Lint / Lint and Check (push) Successful in 52s
2025-08-16 07:05:07 +00:00
dcfd830afe fix(deps): update radix-ui-primitives monorepo
All checks were successful
Lint / Lint and Check (push) Successful in 58s
2025-08-16 06:05:41 +00:00
6145d4549a chore(deps): update typescript-eslint monorepo to v8.39.1
All checks were successful
Lint / Lint and Check (push) Successful in 1m3s
2025-08-16 05:07:26 +00:00
9c99914c36 chore(deps): update tailwindcss monorepo to v4.1.12
All checks were successful
Lint / Lint and Check (push) Successful in 59s
2025-08-16 04:07:38 +00:00
988535d452 chore(deps): update dependency turbo to v2.5.6
All checks were successful
Lint / Lint and Check (push) Successful in 54s
2025-08-16 03:08:16 +00:00
2ece96f3ca chore(deps): update dependency @types/react to v19.1.10
All checks were successful
Lint / Lint and Check (push) Successful in 50s
2025-08-16 02:13:24 +00:00
a0bdda25bc chore(deps): update dependency @types/node to v22.17.2
All checks were successful
Lint / Lint and Check (push) Successful in 49s
2025-08-16 01:11:45 +00:00
778626c3a2 chore(deps): update actions/checkout digest to 08eba0b
All checks were successful
Lint / Lint and Check (push) Successful in 49s
2025-08-16 00:08:16 +00:00
af3e2ceb6b fix(deps): update dependency lucide-react to ^0.539.0
All checks were successful
Lint / Lint and Check (push) Successful in 45s
2025-08-09 05:05:43 +00:00
1cfcd31fff chore(deps): update typescript-eslint monorepo to v8.39.0
All checks were successful
Lint / Lint and Check (push) Successful in 42s
2025-08-09 04:06:46 +00:00
9276e0f037 chore(deps): update eslint monorepo to v9.33.0
All checks were successful
Lint / Lint and Check (push) Successful in 44s
2025-08-09 03:08:05 +00:00
c4bf5f1a35 fix(deps): update nextjs monorepo to v15.4.6
All checks were successful
Lint / Lint and Check (push) Successful in 47s
2025-08-09 02:12:16 +00:00
d480175dd0 fix(deps): update dependency @tanstack/react-query to v5.84.2
All checks were successful
Lint / Lint and Check (push) Successful in 45s
2025-08-09 01:09:58 +00:00
e62cfaa0d4 chore(deps): update dependency @types/node to v22.17.1
All checks were successful
Lint / Lint and Check (push) Successful in 1m40s
2025-08-09 00:08:06 +00:00
095f2c65be fix(deps): update dependency lucide-react to ^0.536.0
All checks were successful
Lint / Lint and Check (push) Successful in 46s
2025-08-02 08:06:24 +00:00
60ce3892d6 fix(deps): update dependency @tanstack/react-query to v5.84.1
All checks were successful
Lint / Lint and Check (push) Successful in 44s
2025-08-02 07:08:37 +00:00
9dff61cbbc chore(deps): update pnpm to v10.14.0
All checks were successful
Lint / Lint and Check (push) Successful in 53s
2025-08-02 06:09:14 +00:00
3c7eeb108b chore(deps): update dependency typescript to v5.9.2
All checks were successful
Lint / Lint and Check (push) Successful in 47s
2025-08-02 05:09:10 +00:00
af7690e66d chore(deps): update dependency @types/node to v22.17.0
All checks were successful
Lint / Lint and Check (push) Successful in 45s
2025-08-02 04:09:51 +00:00
64ef558818 fix(deps): update react monorepo
All checks were successful
Lint / Lint and Check (push) Successful in 54s
2025-08-02 03:13:13 +00:00
6bd6192dd0 fix(deps): update nextjs monorepo to v15.4.5
All checks were successful
Lint / Lint and Check (push) Successful in 54s
2025-08-02 02:20:46 +00:00
43de660f1b fix(deps): update dependency drizzle-orm to v0.44.4
All checks were successful
Lint / Lint and Check (push) Successful in 44s
2025-08-02 01:12:36 +00:00
4bb1943244 chore(deps): update dependency @types/pg to v8.15.5
All checks were successful
Lint / Lint and Check (push) Successful in 43s
2025-08-02 00:09:12 +00:00
0888cca45b fix(deps): update dependency lucide-react to ^0.526.0
All checks were successful
Lint / Lint and Check (push) Successful in 54s
2025-07-26 20:04:14 +00:00
5314c98508 chore(deps): update typescript-eslint monorepo to v8.38.0
All checks were successful
Lint / Lint and Check (push) Successful in 52s
2025-07-26 03:07:57 +00:00
484047a7bd chore(deps): update eslint monorepo to v9.32.0
All checks were successful
Lint / Lint and Check (push) Successful in 47s
2025-07-26 02:12:19 +00:00
80d95065e8 fix(deps): update nextjs monorepo to v15.4.4
All checks were successful
Lint / Lint and Check (push) Successful in 45s
2025-07-26 01:10:21 +00:00
5386dad5c9 fix(deps): update dependency dotenv to v17.2.1
All checks were successful
Lint / Lint and Check (push) Successful in 45s
2025-07-26 00:07:16 +00:00
4e63d0ac42 fix(deps): update nextjs monorepo to v15.4.2
All checks were successful
Lint / Lint and Check (push) Successful in 44s
2025-07-19 03:06:17 +00:00
485e75dc93 chore(deps): update dependency turbo to v2.5.5
All checks were successful
Lint / Lint and Check (push) Successful in 52s
2025-07-19 02:10:23 +00:00
49c8389d9d chore(deps): update dependency @types/node to v22.16.5
All checks were successful
Lint / Lint and Check (push) Successful in 44s
2025-07-19 01:09:05 +00:00
92a27f544b chore(deps): pin dependencies
All checks were successful
Lint / Lint and Check (push) Successful in 1m4s
2025-07-19 00:06:53 +00:00
b02f5e6364 linter fixes, env fixes
All checks were successful
Lint / Lint and Check (push) Successful in 51s
2025-07-15 23:15:32 +02:00
f5fff9c52b fix not able to install on nixos 2025-07-15 21:59:57 +02:00
12 changed files with 1021 additions and 888 deletions

View File

@@ -13,13 +13,13 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- name: Install pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: 22
cache: "pnpm"

View File

@@ -4,16 +4,17 @@ import { generateMemorableToken, isValidToken } from '@/lib/auth/tokens';
import { setTokenCookie, getTokenCookie } from '@/lib/auth/cookies';
import { eq } from 'drizzle-orm';
export async function GET(request: NextRequest) {
export async function GET() {
try {
// Check if user already has a token
const existingToken = await getTokenCookie();
if (existingToken) {
// Verify token exists in database
const [user] = await db.select().from(users).where(eq(users.token, existingToken));
const userRows = await db.select().from(users).where(eq(users.token, existingToken));
if (user) {
if (userRows.length > 0) {
const user = userRows[0];
return NextResponse.json({
authenticated: true,
token: existingToken,
@@ -31,20 +32,25 @@ export async function GET(request: NextRequest) {
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const body = (await request.json()) as { action: string; token?: string };
const { action, token } = body;
if (action === 'create') {
// Generate new token and create user
const newToken = generateMemorableToken();
const [newUser] = await db
const newUserRows = await db
.insert(users)
.values({
token: newToken,
})
.returning();
if (newUserRows.length === 0) {
throw new Error('Failed to create user');
}
const newUser = newUserRows[0];
await setTokenCookie(newToken);
return NextResponse.json({
@@ -67,9 +73,9 @@ export async function POST(request: NextRequest) {
}
// Check if token exists
const [user] = await db.select().from(users).where(eq(users.token, token));
const userRows = await db.select().from(users).where(eq(users.token, token));
if (!user) {
if (userRows.length === 0) {
return NextResponse.json(
{
success: false,
@@ -79,6 +85,7 @@ export async function POST(request: NextRequest) {
);
}
const user = userRows[0];
await setTokenCookie(token);
return NextResponse.json({

View File

@@ -7,8 +7,8 @@ async function getUserFromToken() {
const token = await getTokenCookie();
if (!token) return null;
const [user] = await db.select().from(users).where(eq(users.token, token));
return user;
const userRows = await db.select().from(users).where(eq(users.token, token));
return userRows.length > 0 ? userRows[0] : null;
}
export async function POST(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
@@ -26,20 +26,20 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
}
// Verify habit belongs to user
const [habit] = await db
const habitRows = await db
.select()
.from(habits)
.where(and(eq(habits.id, habitId), eq(habits.userId, user.id)));
if (!habit) {
if (habitRows.length === 0) {
return NextResponse.json({ error: 'Habit not found' }, { status: 404 });
}
const body = await request.json();
const body = (await request.json()) as { note?: string };
const { note } = body;
// Create log entry
const [log] = await db
const logRows = await db
.insert(habitLogs)
.values({
habitId,
@@ -47,6 +47,11 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
})
.returning();
if (logRows.length === 0) {
throw new Error('Failed to create log entry');
}
const log = logRows[0];
return NextResponse.json({ log });
} catch (error) {
console.error('Log habit error:', error);

View File

@@ -7,11 +7,11 @@ async function getUserFromToken() {
const token = await getTokenCookie();
if (!token) return null;
const [user] = await db.select().from(users).where(eq(users.token, token));
return user;
const userRows = await db.select().from(users).where(eq(users.token, token));
return userRows.length > 0 ? userRows[0] : null;
}
export async function GET(request: NextRequest) {
export async function GET() {
try {
const user = await getUserFromToken();
if (!user) {
@@ -83,7 +83,13 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const body = await request.json();
const body = (await request.json()) as {
name: string;
type: string;
targetFrequency?: { value: number; period: 'day' | 'week' | 'month' };
color?: string;
icon?: string;
};
const { name, type, targetFrequency, color, icon } = body;
if (!name || !type) {
@@ -95,18 +101,33 @@ export async function POST(request: NextRequest) {
);
}
const [newHabit] = await db
// Validate type is one of the allowed enum values
if (!['positive', 'neutral', 'negative'].includes(type)) {
return NextResponse.json(
{
error: 'Type must be one of: positive, neutral, negative',
},
{ status: 400 },
);
}
const newHabitRows = await db
.insert(habits)
.values({
userId: user.id,
name,
type,
type: type as 'positive' | 'neutral' | 'negative',
targetFrequency,
color,
icon,
})
.returning();
if (newHabitRows.length === 0) {
throw new Error('Failed to create habit');
}
const newHabit = newHabitRows[0];
return NextResponse.json({ habit: newHabit });
} catch (error) {
console.error('Create habit error:', error);

View File

@@ -36,6 +36,12 @@ import { Alert, AlertDescription } from '@/components/ui/alert';
import { Separator } from '@/components/ui/separator';
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
interface AuthData {
authenticated: boolean;
token?: string;
userId?: string;
}
interface Habit {
id: number;
name: string;
@@ -47,6 +53,23 @@ interface Habit {
createdAt: string;
}
interface HabitsResponse {
habits: Habit[];
}
interface LogResponse {
log: {
id: number;
habitId: number;
loggedAt: string;
note?: string;
};
}
interface HabitResponse {
habit: Habit;
}
export default function Dashboard() {
const router = useRouter();
const queryClient = useQueryClient();
@@ -57,11 +80,11 @@ export default function Dashboard() {
const [copiedToken, setCopiedToken] = useState(false);
// Check authentication
const { data: authData, isLoading: authLoading } = useQuery({
const { data: authData, isLoading: authLoading } = useQuery<AuthData>({
queryKey: ['auth'],
queryFn: async () => {
queryFn: async (): Promise<AuthData> => {
const res = await fetch('/api/auth');
const data = await res.json();
const data = (await res.json()) as AuthData;
if (!data.authenticated) {
router.push('/');
}
@@ -76,45 +99,45 @@ export default function Dashboard() {
}, [authData]);
// Fetch habits
const { data: habitsData, isLoading: habitsLoading } = useQuery({
const { data: habitsData, isLoading: habitsLoading } = useQuery<HabitsResponse>({
queryKey: ['habits'],
queryFn: async () => {
queryFn: async (): Promise<HabitsResponse> => {
const res = await fetch('/api/habits');
if (!res.ok) throw new Error('Failed to fetch habits');
return res.json();
return res.json() as Promise<HabitsResponse>;
},
enabled: !!authData?.authenticated,
});
// Log habit mutation
const logHabitMutation = useMutation({
mutationFn: async (habitId: number) => {
const res = await fetch(`/api/habits/${habitId}/log`, {
const logHabitMutation = useMutation<LogResponse, Error, number>({
mutationFn: async (habitId: number): Promise<LogResponse> => {
const res = await fetch(`/api/habits/${String(habitId)}/log`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({}),
});
if (!res.ok) throw new Error('Failed to log habit');
return res.json();
return res.json() as Promise<LogResponse>;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['habits'] });
void queryClient.invalidateQueries({ queryKey: ['habits'] });
},
});
// Create habit mutation
const createHabitMutation = useMutation({
mutationFn: async (data: { name: string; type: string }) => {
const createHabitMutation = useMutation<HabitResponse, Error, { name: string; type: string }>({
mutationFn: async (data: { name: string; type: string }): Promise<HabitResponse> => {
const res = await fetch('/api/habits', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
if (!res.ok) throw new Error('Failed to create habit');
return res.json();
return res.json() as Promise<HabitResponse>;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['habits'] });
void queryClient.invalidateQueries({ queryKey: ['habits'] });
setShowNewHabitDialog(false);
setNewHabitName('');
setNewHabitType('neutral');
@@ -132,9 +155,11 @@ export default function Dashboard() {
const copyToken = () => {
if (userToken) {
navigator.clipboard.writeText(userToken);
void navigator.clipboard.writeText(userToken);
setCopiedToken(true);
setTimeout(() => setCopiedToken(false), 2000);
setTimeout(() => {
setCopiedToken(false);
}, 2000);
}
};
@@ -199,7 +224,7 @@ export default function Dashboard() {
);
}
const habits = habitsData?.habits || [];
const habits = habitsData?.habits ?? [];
return (
<div className="min-h-screen bg-black">
@@ -233,13 +258,20 @@ export default function Dashboard() {
id="name"
placeholder="e.g., Exercise, Read, Meditate..."
value={newHabitName}
onChange={(e) => setNewHabitName(e.target.value)}
onChange={(e) => {
setNewHabitName(e.target.value);
}}
className="border-zinc-800 bg-zinc-900"
/>
</div>
<div className="grid gap-2">
<Label htmlFor="type">Habit Type</Label>
<Select value={newHabitType} onValueChange={(value: any) => setNewHabitType(value)}>
<Select
value={newHabitType}
onValueChange={(value: 'positive' | 'neutral' | 'negative') => {
setNewHabitType(value);
}}
>
<SelectTrigger className="border-zinc-800 bg-zinc-900">
<SelectValue />
</SelectTrigger>
@@ -267,7 +299,12 @@ export default function Dashboard() {
</div>
</div>
<DialogFooter>
<Button variant="outline" onClick={() => setShowNewHabitDialog(false)}>
<Button
variant="outline"
onClick={() => {
setShowNewHabitDialog(false);
}}
>
Cancel
</Button>
<Button
@@ -317,7 +354,9 @@ export default function Dashboard() {
className={`transform cursor-pointer transition-all duration-200 hover:scale-[1.02] ${getHabitCardClass(
habit.type,
)} ${logHabitMutation.isPending ? 'opacity-75' : ''}`}
onClick={() => logHabitMutation.mutate(habit.id)}
onClick={() => {
logHabitMutation.mutate(habit.id);
}}
>
<CardHeader className="pb-3">
<div className="flex items-start justify-between">
@@ -384,7 +423,9 @@ export default function Dashboard() {
<h3 className="mb-2 text-lg font-semibold">No habits yet</h3>
<p className="mb-4 text-sm text-zinc-500">Start building better habits today</p>
<Button
onClick={() => setShowNewHabitDialog(true)}
onClick={() => {
setShowNewHabitDialog(true);
}}
className="bg-emerald-600 hover:bg-emerald-700"
>
<Plus className="mr-2 h-4 w-4" />

View File

@@ -9,7 +9,14 @@ import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Alert, AlertDescription } from '@/components/ui/alert';
import { Separator } from '@/components/ui/separator';
import { LogIn, Sparkles, Shield, Zap, ArrowLeft } from 'lucide-react';
import { LogIn, Shield, Zap, ArrowLeft, Activity, CalendarCheck } from 'lucide-react';
interface AuthResponse {
success?: boolean;
token?: string;
userId?: string;
error?: string;
}
export default function Welcome() {
const router = useRouter();
@@ -18,14 +25,14 @@ export default function Welcome() {
const [error, setError] = useState('');
const createAccountMutation = useMutation({
mutationFn: async () => {
mutationFn: async (): Promise<AuthResponse> => {
const res = await fetch('/api/auth', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'create' }),
});
if (!res.ok) throw new Error('Failed to create account');
return res.json();
return res.json() as Promise<AuthResponse>;
},
onSuccess: () => {
router.push('/dashboard');
@@ -36,17 +43,17 @@ export default function Welcome() {
});
const loginMutation = useMutation({
mutationFn: async (token: string) => {
mutationFn: async (token: string): Promise<AuthResponse> => {
const res = await fetch('/api/auth', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'login', token }),
});
if (!res.ok) {
const data = await res.json();
throw new Error(data.error || 'Failed to login');
const data = (await res.json()) as AuthResponse;
throw new Error(data.error ?? 'Failed to login');
}
return res.json();
return res.json() as Promise<AuthResponse>;
},
onSuccess: () => {
router.push('/dashboard');
@@ -63,6 +70,12 @@ export default function Welcome() {
}
};
const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
handleTokenLogin();
}
};
return (
<Card className="w-full max-w-md border-zinc-800 bg-zinc-950">
<CardHeader className="space-y-2 text-center">
@@ -93,7 +106,7 @@ export default function Welcome() {
</div>
<div className="flex items-center gap-3">
<div className="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg bg-emerald-950">
<Sparkles className="h-4 w-4 text-emerald-500" />
<Activity className="h-4 w-4 text-emerald-500" />
</div>
<p className="text-zinc-400">Track positive, neutral, or negative habits</p>
</div>
@@ -104,7 +117,9 @@ export default function Welcome() {
{/* Actions */}
<div className="space-y-3">
<Button
onClick={() => createAccountMutation.mutate()}
onClick={() => {
createAccountMutation.mutate();
}}
disabled={createAccountMutation.isPending}
className="w-full bg-emerald-600 text-white hover:bg-emerald-700"
size="lg"
@@ -113,7 +128,7 @@ export default function Welcome() {
<>Creating your account...</>
) : (
<>
<Sparkles className="mr-2 h-4 w-4" />
<CalendarCheck className="mr-2 h-4 w-4" />
Start Tracking Now
</>
)}
@@ -130,7 +145,9 @@ export default function Welcome() {
<Button
variant="outline"
onClick={() => setShowTokenInput(true)}
onClick={() => {
setShowTokenInput(true);
}}
className="w-full border-zinc-800 hover:bg-zinc-900"
size="lg"
>
@@ -161,8 +178,10 @@ export default function Welcome() {
type="text"
placeholder="e.g., happy-blue-cat-1234"
value={tokenInput}
onChange={(e) => setTokenInput(e.target.value)}
onKeyPress={(e) => e.key === 'Enter' && handleTokenLogin()}
onChange={(e) => {
setTokenInput(e.target.value);
}}
onKeyDown={handleKeyDown}
className="border-zinc-800 bg-zinc-900 placeholder:text-zinc-600"
autoFocus
/>

View File

@@ -1,11 +1,17 @@
import { defineConfig } from 'drizzle-kit';
import { env } from 'node:process';
import dotenv from 'dotenv';
dotenv.config({ path: ['.env.local', '.env'] });
const DATABASE_URL = process.env.POSTGRES_URL;
if (!DATABASE_URL) {
throw new Error('POSTGRES_URL environment variable is required');
}
export default defineConfig({
schema: './lib/db/schema.ts',
dialect: 'postgresql',
dbCredentials: {
url: env.POSTGRES_URL!,
url: DATABASE_URL,
},
out: './drizzle',
});

View File

@@ -1,8 +1,14 @@
import { drizzle } from 'drizzle-orm/node-postgres';
import * as schema from './schema';
import 'dotenv/config';
import dotenv from 'dotenv';
dotenv.config({ path: ['.env.local', '.env'] });
export const db = drizzle(process.env.POSTGRES_URL!, { schema });
const DATABASE_URL = process.env.POSTGRES_URL;
if (!DATABASE_URL) {
throw new Error('POSTGRES_URL environment variable is required');
}
export const db = drizzle(DATABASE_URL, { schema });
// Re-export schema types for convenience
export * from './schema';

View File

@@ -28,9 +28,7 @@ export const habits = pgTable(
createdAt: timestamp('created_at').defaultNow().notNull(),
archivedAt: timestamp('archived_at'),
},
(table) => ({
userIdIdx: index('habits_user_id_idx').on(table.userId),
}),
(table) => [index('habits_user_id_idx').on(table.userId)],
);
export const habitLogs = pgTable(
@@ -43,10 +41,10 @@ export const habitLogs = pgTable(
loggedAt: timestamp('logged_at').defaultNow().notNull(),
note: text('note'),
},
(table) => ({
habitIdIdx: index('habit_logs_habit_id_idx').on(table.habitId),
loggedAtIdx: index('habit_logs_logged_at_idx').on(table.loggedAt),
}),
(table) => [
index('habit_logs_habit_id_idx').on(table.habitId),
index('habit_logs_logged_at_idx').on(table.loggedAt),
],
);
// Relations

View File

@@ -29,39 +29,39 @@
"date-fns": "^4.1.0",
"dotenv": "^17.2.0",
"drizzle-orm": "^0.44.3",
"lucide-react": "^0.525.0",
"lucide-react": "^0.542.0",
"nanoid": "^5.1.5",
"next": "15.4.1",
"next": "15.5.2",
"next-plausible": "^3.12.4",
"pg": "^8.16.3",
"pg-native": "^3.5.2",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^10.2.4",
"react": "19.1.0",
"react-dom": "19.1.0",
"react": "19.1.1",
"react-dom": "19.1.1",
"tailwind-merge": "^3.3.1",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@eslint/js": "^9.31.0",
"@next/eslint-plugin-next": "^15.4.1",
"@tailwindcss/postcss": "4.1.11",
"@types/node": "22.16.3",
"@types/pg": "^8.15.4",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
"@typescript-eslint/eslint-plugin": "^8.37.0",
"@typescript-eslint/parser": "^8.37.0",
"drizzle-kit": "^0.31.4",
"eslint": "9.31.0",
"eslint-config-next": "15.4.1",
"@eslint/js": "9.34.0",
"@next/eslint-plugin-next": "15.5.2",
"@tailwindcss/postcss": "4.1.12",
"@types/node": "22.18.0",
"@types/pg": "8.15.5",
"@types/react": "19.1.12",
"@types/react-dom": "19.1.9",
"@typescript-eslint/eslint-plugin": "8.41.0",
"@typescript-eslint/parser": "8.41.0",
"drizzle-kit": "0.31.4",
"eslint": "9.34.0",
"eslint-config-next": "15.5.2",
"postcss": "8.5.6",
"prettier": "^3.6.2",
"prettier-plugin-tailwindcss": "^0.6.14",
"tailwindcss": "4.1.11",
"turbo": "2.5.4",
"typescript": "5.8.3",
"typescript-eslint": "^8.37.0"
"prettier": "3.6.2",
"prettier-plugin-tailwindcss": "0.6.14",
"tailwindcss": "4.1.12",
"turbo": "2.5.6",
"typescript": "5.9.2",
"typescript-eslint": "8.41.0"
},
"packageManager": "pnpm@10.13.1"
"packageManager": "pnpm@10.15.0"
}

1623
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,3 @@
onlyBuiltDependencies:
- '@tailwindcss/oxide'
- libpq
- sharp