Merge branch 'main' into feat-endpoint-style-structure

This commit is contained in:
Daniel Avila 2023-04-01 19:41:36 -04:00
commit 8fa20d9356
18 changed files with 2281 additions and 24 deletions

View file

@ -23,7 +23,7 @@ const projectPath = path.join(__dirname, '..', '..', 'client');
app.use(errorController);
app.use(cors());
app.use(express.json());
app.use(express.static(path.join(projectPath, 'public')));
app.use(express.static(path.join(projectPath, 'dist')));
app.set('trust proxy', 1); // trust first proxy
app.use(
session({
@ -73,7 +73,7 @@ const projectPath = path.join(__dirname, '..', '..', 'client');
});
app.get('/*', routes.authenticatedOrRedirect, function (req, res) {
res.sendFile(path.join(projectPath, 'public', 'index.html'));
res.sendFile(path.join(projectPath, 'dist', 'index.html'));
});
app.listen(port, host, () => {

View file

@ -26,15 +26,16 @@
/>
<script
defer
src="/main.js"
type="module"
src="/src/main.jsx"
></script>
</head>
<body>
<div id="root"></div>
<script
type="text/javascript"
src="/main.js"
type="module"
src="/src/main.jsx"
></script>
</body>
</html>

View file

@ -2,9 +2,11 @@
"name": "chatgpt-clone",
"version": "0.2.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"build": "webpack",
"build": "vite build",
"dev": "vite",
"preview-prod": "vite preview",
"build-dev": "Webpack . --watch"
},
"repository": {

View file

@ -0,0 +1,8 @@
module.exports = {
plugins: [
require("postcss-import"),
require("postcss-preset-env"),
require("tailwindcss"),
require("autoprefixer"),
]
};

View file

@ -1,2 +0,0 @@
const tailwindcss = require('tailwindcss');
module.exports = { plugins: ['postcss-preset-env', tailwindcss] };

View file

@ -16,11 +16,12 @@ export default function Conversation({ conversation, retainView }) {
const { switchToConversation } = store.useConversation();
const [renaming, setRenaming] = useState(false);
const [titleInput, setTitleInput] = useState(title);
const inputRef = useRef(null);
const { conversationId, title } = conversation;
const [titleInput, setTitleInput] = useState(title);
const rename = manualSWR(`/api/convos/update`, 'post');
const clickHandler = async () => {

View file

@ -1,6 +1,6 @@
import { useEffect } from 'react';
import { useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil';
import { SSE } from '~/utils/sse';
import { SSE } from '~/utils/sse.mjs';
import createPayload from '~/utils/createPayload';
import store from '~/store';

View file

@ -6,7 +6,7 @@ import remarkMath from 'remark-math';
import remarkGfm from 'remark-gfm';
import rehypeRaw from 'rehype-raw'
import CodeBlock from './CodeBlock';
import { langSubset } from '~/utils/languages';
import { langSubset } from '~/utils/languages.mjs';
const Content = React.memo(({ content }) => {
let rehypePlugins = [

View file

@ -42,5 +42,5 @@ export const ThemeProvider = ({ initialTheme, children }) => {
rawSetTheme(theme);
}, [theme]);
return <ThemeContext.Provider value={{ theme, setTheme }}>{children}</ThemeContext.Provider>;
return <ThemeContext.Provider value={{ theme, setTheme }}>{children}</ThemeContext.Provider>
};

View file

@ -4,10 +4,10 @@ import { createRoot } from 'react-dom/client';
// import { store } from './src/store';
import { RecoilRoot } from 'recoil';
import { ThemeProvider } from './src/hooks/ThemeContext';
import App from './src/App';
import './src/style.css';
import './src/mobile.css';
import { ThemeProvider } from './hooks/ThemeContext';
import App from './App';
import './style.css';
import './mobile.css';
const container = document.getElementById('root');
const root = createRoot(container);

View file

@ -353,4 +353,4 @@ const langSubset = [
'yaml',
];
module.exports = { languages, langSubset };
export { languages, langSubset };

View file

@ -211,8 +211,9 @@ var SSE = function (url, options) {
};
};
export { SSE };
// Export our SSE module for npm.js
if (typeof exports !== 'undefined') {
// exports.SSE = SSE;
module.exports = { SSE };
}
// if (typeof exports !== 'undefined') {
// // exports.SSE = SSE;
// module.exports = { SSE };
// }

View file

@ -1,9 +1,31 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": false,
"module": "ESNext",
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"isolatedModules": true,
"noImplicitAny": false,
"noEmit": false,
"jsx": "react-jsx",
"baseUrl": ".",
"jsx": "react",
"paths": {
"~/*": ["./src/*"]
}
}
},
"include": [
"src"
],
}

29
client/vite.config.ts Normal file
View file

@ -0,0 +1,29 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
server: {
host: "localhost",
port: 3090,
strictPort: false,
proxy: {
"/api": {
target: "http://localhost:3080",
changeOrigin: true,
}
}
},
plugins: [react()],
publicDir: "./public",
build: {
sourcemap: true,
outDir: "./dist",
},
resolve: {
alias: {
"~": path.join(__dirname, "src/"),
},
},
});

2188
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

7
package.json Normal file
View file

@ -0,0 +1,7 @@
{
"devDependencies": {
"@vitejs/plugin-react": "^3.1.0",
"vite": "^4.2.1",
"vite-plugin-html": "^3.2.0"
}
}