Skip to content

Commit de50f77

Browse files
Merge branch 'main' into live
2 parents 71b8be5 + 9dcdb7b commit de50f77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+4289
-4805
lines changed

.eslintrc.json

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,10 @@
66
"prettier",
77
"plugin:tailwindcss/recommended"
88
],
9-
"plugins": ["import", "tailwindcss"],
9+
"plugins": ["tailwindcss"],
1010
"rules": {
1111
"tailwindcss/no-custom-classname": "off",
12-
"tailwindcss/classnames-order": "off",
13-
"import/order": [
14-
"error",
15-
{
16-
"groups": [
17-
"builtin",
18-
"external",
19-
"internal",
20-
["parent", "sibling"],
21-
"index",
22-
"object",
23-
"type"
24-
],
25-
"newlines-between": "always",
26-
"alphabetize": {
27-
"order": "asc",
28-
"caseInsensitive": true
29-
}
30-
}
31-
]
12+
"tailwindcss/classnames-order": "off"
3213
},
3314
"settings": {
3415
"import/resolver": {

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
on:
3+
push:
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-22.04
8+
strategy:
9+
matrix:
10+
node-version: [20]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Install pnpm
14+
uses: pnpm/action-setup@v4
15+
with:
16+
version: 9
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
cache: 'pnpm'
22+
- name: Install dependencies
23+
run: pnpm install
24+
- name: Run lint
25+
run: pnpm lint

app/(auth)/actions.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { z } from 'zod';
44

5-
import { createUser, getUser } from '@/db/queries';
5+
import { createUser, getUser } from '@/lib/db/queries';
66

77
import { signIn } from './auth';
88

@@ -17,7 +17,7 @@ export interface LoginActionState {
1717

1818
export const login = async (
1919
_: LoginActionState,
20-
formData: FormData
20+
formData: FormData,
2121
): Promise<LoginActionState> => {
2222
try {
2323
const validatedData = authFormSchema.parse({
@@ -53,28 +53,27 @@ export interface RegisterActionState {
5353

5454
export const register = async (
5555
_: RegisterActionState,
56-
formData: FormData
56+
formData: FormData,
5757
): Promise<RegisterActionState> => {
5858
try {
5959
const validatedData = authFormSchema.parse({
6060
email: formData.get('email'),
6161
password: formData.get('password'),
6262
});
6363

64-
let [user] = await getUser(validatedData.email);
64+
const [user] = await getUser(validatedData.email);
6565

6666
if (user) {
6767
return { status: 'user_exists' } as RegisterActionState;
68-
} else {
69-
await createUser(validatedData.email, validatedData.password);
70-
await signIn('credentials', {
71-
email: validatedData.email,
72-
password: validatedData.password,
73-
redirect: false,
74-
});
75-
76-
return { status: 'success' };
7768
}
69+
await createUser(validatedData.email, validatedData.password);
70+
await signIn('credentials', {
71+
email: validatedData.email,
72+
password: validatedData.password,
73+
redirect: false,
74+
});
75+
76+
return { status: 'success' };
7877
} catch (error) {
7978
if (error instanceof z.ZodError) {
8079
return { status: 'invalid_data' };

app/(auth)/auth.config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { NextAuthConfig } from 'next-auth';
1+
import type { NextAuthConfig } from "next-auth";
22

33
export const authConfig = {
44
pages: {
5-
signIn: '/login',
6-
newUser: '/',
5+
signIn: "/login",
6+
newUser: "/",
77
},
88
providers: [
99
// added later in auth.ts since it requires bcrypt which is only compatible with Node.js
@@ -13,11 +13,11 @@ export const authConfig = {
1313
authorized({ auth, request: { nextUrl } }) {
1414
let isLoggedIn = !!auth?.user;
1515
// let isOnChat = nextUrl.pathname.startsWith("/");
16-
let isOnRegister = nextUrl.pathname.startsWith('/register');
17-
let isOnLogin = nextUrl.pathname.startsWith('/login');
16+
let isOnRegister = nextUrl.pathname.startsWith("/register");
17+
let isOnLogin = nextUrl.pathname.startsWith("/login");
1818

1919
if (isLoggedIn && (isOnLogin || isOnRegister)) {
20-
return Response.redirect(new URL('/', nextUrl as unknown as URL));
20+
return Response.redirect(new URL("/", nextUrl as unknown as URL));
2121
}
2222

2323
if (isOnRegister || isOnLogin) {

app/(auth)/auth.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { compare } from 'bcrypt-ts';
2-
import NextAuth, { User, Session } from 'next-auth';
2+
import NextAuth, { type User, type Session } from 'next-auth';
33
import Credentials from 'next-auth/providers/credentials';
44

5-
import { getUser } from '@/db/queries';
5+
import { getUser } from '@/lib/db/queries';
66

77
import { authConfig } from './auth.config';
88

@@ -21,10 +21,12 @@ export const {
2121
Credentials({
2222
credentials: {},
2323
async authorize({ email, password }: any) {
24-
let users = await getUser(email);
24+
const users = await getUser(email);
2525
if (users.length === 0) return null;
26-
let passwordsMatch = await compare(password, users[0].password!);
27-
if (passwordsMatch) return users[0] as any;
26+
// biome-ignore lint: Forbidden non-null assertion.
27+
const passwordsMatch = await compare(password, users[0].password!);
28+
if (!passwordsMatch) return null;
29+
return users[0] as any;
2830
},
2931
}),
3032
],

app/(auth)/login/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { useRouter } from 'next/navigation';
55
import { useActionState, useEffect, useState } from 'react';
66
import { toast } from 'sonner';
77

8-
import { AuthForm } from '@/components/custom/auth-form';
9-
import { SubmitButton } from '@/components/custom/submit-button';
8+
import { AuthForm } from '@/components/auth-form';
9+
import { SubmitButton } from '@/components/submit-button';
1010

11-
import { login, LoginActionState } from '../actions';
11+
import { login, type LoginActionState } from '../actions';
1212

1313
export default function Page() {
1414
const router = useRouter();
@@ -20,7 +20,7 @@ export default function Page() {
2020
login,
2121
{
2222
status: 'idle',
23-
}
23+
},
2424
);
2525

2626
useEffect(() => {

app/(auth)/register/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { useRouter } from 'next/navigation';
55
import { useActionState, useEffect, useState } from 'react';
66
import { toast } from 'sonner';
77

8-
import { AuthForm } from '@/components/custom/auth-form';
9-
import { SubmitButton } from '@/components/custom/submit-button';
8+
import { AuthForm } from '@/components/auth-form';
9+
import { SubmitButton } from '@/components/submit-button';
1010

11-
import { register, RegisterActionState } from '../actions';
11+
import { register, type RegisterActionState } from '../actions';
1212

1313
export default function Page() {
1414
const router = useRouter();
@@ -20,7 +20,7 @@ export default function Page() {
2020
register,
2121
{
2222
status: 'idle',
23-
}
23+
},
2424
);
2525

2626
useEffect(() => {

app/(chat)/actions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use server';
22

3-
import { CoreMessage, CoreUserMessage, generateText } from 'ai';
3+
import { type CoreUserMessage, generateText } from 'ai';
44
import { cookies } from 'next/headers';
55

6-
import { customModel } from '@/ai';
6+
import { customModel } from '@/lib/ai';
77

88
export async function saveModelId(model: string) {
99
const cookieStore = await cookies();
@@ -16,7 +16,7 @@ export async function generateTitleFromUserMessage({
1616
message: CoreUserMessage;
1717
}) {
1818
const { text: title } = await generateText({
19-
model: customModel('gpt-3.5-turbo'),
19+
model: customModel('gpt-4o-mini'),
2020
system: `\n
2121
- you will generate a short title based on the first message a user begins a conversation with
2222
- ensure it is not more than 80 characters long

0 commit comments

Comments
 (0)