Skip to content

Commit

Permalink
Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
burakorkmez committed Jan 31, 2024
1 parent 66a6766 commit e2144ac
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
12 changes: 8 additions & 4 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "path";
import express from "express";
import dotenv from "dotenv";
import cookieParser from "cookie-parser";
Expand All @@ -11,6 +12,8 @@ import { app, server } from "./socket/socket.js";

const PORT = process.env.PORT || 5000;

const __dirname = path.resolve();

dotenv.config();

app.use(express.json()); // to parse the incoming requests with JSON payloads (from req.body)
Expand All @@ -20,10 +23,11 @@ app.use("/api/auth", authRoutes);
app.use("/api/messages", messageRoutes);
app.use("/api/users", userRoutes);

// app.get("/", (req, res) => {
// root route http://localhost:5000/
// res.send("Hello World!!");
// });
app.use(express.static(path.join(__dirname, "/frontend/dist")));

app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "frontend", "dist", "index.html"));
});

server.listen(PORT, () => {
connectToMongoDB();
Expand Down
21 changes: 21 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"chat-app-yt": "file:..",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "",
"main": "server.js",
"scripts": {
"server": "nodemon backend/server.js"
"server": "nodemon backend/server.js",
"start": "node backend/server.js",
"build": "npm install && npm install --prefix frontend && npm run build --prefix frontend"
},
"type": "module",
"keywords": [],
Expand Down

0 comments on commit e2144ac

Please sign in to comment.