diff --git a/components/ChatView/Header.tsx b/components/ChatView/Header.tsx index 0c30cb2..64b7ea4 100644 --- a/components/ChatView/Header.tsx +++ b/components/ChatView/Header.tsx @@ -1,7 +1,7 @@ import { Menu, Popover } from "@headlessui/react"; import Link from "next/link"; import { toast } from "react-hot-toast"; -import { getAssistantById, useChatStore, useMessageStore } from "../../store"; +import { getAssistantById, useChatStore, useMessageStore } from "@/store"; import Icon from "../Icon"; const Header = () => { diff --git a/components/ChatView/MessageTextarea.tsx b/components/ChatView/MessageTextarea.tsx index 2e082cc..ceeb5c0 100644 --- a/components/ChatView/MessageTextarea.tsx +++ b/components/ChatView/MessageTextarea.tsx @@ -1,9 +1,9 @@ import { useEffect, useRef, useState } from "react"; import { toast } from "react-hot-toast"; import TextareaAutosize from "react-textarea-autosize"; -import { localUser, useChatStore, useMessageStore } from "../../store"; -import { CreatorRole } from "../../types"; -import { generateUUID } from "../../utils"; +import { localUser, useChatStore, useMessageStore } from "@/store"; +import { CreatorRole } from "@/types"; +import { generateUUID } from "@/utils"; import Icon from "../Icon"; interface Props { diff --git a/components/ChatView/MessageView.tsx b/components/ChatView/MessageView.tsx index 192f61d..afcbddf 100644 --- a/components/ChatView/MessageView.tsx +++ b/components/ChatView/MessageView.tsx @@ -1,6 +1,6 @@ import { marked } from "marked"; -import { localUser } from "../../store"; -import { Message } from "../../types"; +import { localUser } from "@/store"; +import { Message } from "@/types"; interface Props { message: Message; diff --git a/components/ChatView/index.tsx b/components/ChatView/index.tsx index cd9d0d7..6d26bfe 100644 --- a/components/ChatView/index.tsx +++ b/components/ChatView/index.tsx @@ -1,8 +1,8 @@ import axios from "axios"; import { useEffect, useRef, useState } from "react"; -import { defaultChat, getAssistantById, getPromptOfAssistant, localUser, useChatStore, useMessageStore } from "../../store"; -import { Chat, CreatorRole, Message } from "../../types"; -import { generateUUID } from "../../utils"; +import { defaultChat, getAssistantById, getPromptOfAssistant, localUser, useChatStore, useMessageStore } from "@/store"; +import { Chat, CreatorRole, Message } from "@/types"; +import { generateUUID } from "@/utils"; import Icon from "../Icon"; import Header from "./Header"; import MessageView from "./MessageView"; diff --git a/pages/_app.tsx b/pages/_app.tsx index 14decd5..fff52a5 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -2,8 +2,8 @@ import { AppProps } from "next/app"; import React from "react"; import { Toaster } from "react-hot-toast"; import { Analytics } from "@vercel/analytics/react"; -import "../styles/tailwind.css"; -import "../styles/global.css"; +import "@/styles/tailwind.css"; +import "@/styles/global.css"; function MyApp({ Component, pageProps }: AppProps) { return ( diff --git a/pages/about.tsx b/pages/about.tsx index 4e04899..ee8b799 100644 --- a/pages/about.tsx +++ b/pages/about.tsx @@ -2,7 +2,7 @@ import { NextPage } from "next"; import Head from "next/head"; import Link from "next/link"; import React from "react"; -import Icon from "../components/Icon"; +import Icon from "@/components/Icon"; const HomePage: NextPage = () => { return ( diff --git a/pages/api/chat.ts b/pages/api/chat.ts index bc9ea52..8d34111 100644 --- a/pages/api/chat.ts +++ b/pages/api/chat.ts @@ -1,5 +1,5 @@ import { NextApiRequest, NextApiResponse } from "next"; -import openai from "../../utils/openai-api"; +import openai from "@/utils/openai-api"; const handler = async (req: NextApiRequest, res: NextApiResponse) => { const completionResponse = await openai.createChatCompletion({ diff --git a/pages/index.tsx b/pages/index.tsx index 8a3b151..b9308b1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,7 +1,7 @@ import { NextPage } from "next"; import Head from "next/head"; import React from "react"; -import ChatView from "../components/ChatView"; +import ChatView from "@/components/ChatView"; const ChatPage: NextPage = () => { return ( diff --git a/store/assistant.ts b/store/assistant.ts index 8fc5827..1d2c2b4 100644 --- a/store/assistant.ts +++ b/store/assistant.ts @@ -1,5 +1,5 @@ import { first } from "lodash-es"; -import { Id, User } from "../types"; +import { Id, User } from "@/types"; // Assistant is a special user. export const assistantList: User[] = [ diff --git a/store/chat.ts b/store/chat.ts index c43beff..7a0c75b 100644 --- a/store/chat.ts +++ b/store/chat.ts @@ -1,7 +1,7 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; -import { Chat, UNKNOWN_ID, User } from "../types"; -import { generateUUID } from "../utils"; +import { Chat, UNKNOWN_ID, User } from "@/types"; +import { generateUUID } from "@/utils"; export const defaultChat: Chat = { id: generateUUID(), diff --git a/store/message.ts b/store/message.ts index fc1a620..4413bec 100644 --- a/store/message.ts +++ b/store/message.ts @@ -1,6 +1,6 @@ import { create } from "zustand"; import { persist } from "zustand/middleware"; -import { Message } from "../types"; +import { Message } from "@/types"; interface MessageState { messageList: Message[]; diff --git a/store/user.ts b/store/user.ts index fb08010..e410c90 100644 --- a/store/user.ts +++ b/store/user.ts @@ -1,4 +1,4 @@ -import { User } from "../types"; +import { User } from "@/types"; export const localUser: User = { id: "local-user", diff --git a/tsconfig.json b/tsconfig.json index 99710e8..8b8e581 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,10 @@ "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", - "incremental": true + "incremental": true, + "paths": { + "@/*": ["./*"] + } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] diff --git a/types/chat.ts b/types/chat.ts index 1822194..e0a86b2 100644 --- a/types/chat.ts +++ b/types/chat.ts @@ -1,4 +1,4 @@ -import { Id } from "./common"; +import { Id } from "./"; export interface Chat { id: string; diff --git a/types/connection.ts b/types/connection.ts index e5c4480..fcc3e96 100644 --- a/types/connection.ts +++ b/types/connection.ts @@ -1,4 +1,4 @@ -import { Id } from "./common"; +import { Id } from "./"; enum Engine { MySQL = "MYSQL", diff --git a/types/database.ts b/types/database.ts index 277b2a6..43eeaca 100644 --- a/types/database.ts +++ b/types/database.ts @@ -1,4 +1,4 @@ -import { Id } from "./common"; +import { Id } from "./"; export interface Database { connectionId: Id; diff --git a/types/index.ts b/types/index.ts index ff6f2e3..d1d5b53 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,4 +1,6 @@ export * from "./common"; export * from "./user"; +export * from "./connection"; +export * from "./database"; export * from "./chat"; export * from "./message";