Skip to content

Commit d392198

Browse files
committed
make changes for deployment
Signed-off-by: Amit Amrutiya <amitamrutiya2210@gmail.com>
1 parent ad58804 commit d392198

File tree

5 files changed

+161
-4
lines changed

5 files changed

+161
-4
lines changed

backend/index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ import mergedTypeDefs from "./typeDefs/index.js";
1717

1818
import { connectDB } from "./db/connectDB.js";
1919
import { configurePassport } from "./passport/passport.config.js";
20+
import job from "./cron.js";
2021

2122
configurePassport();
2223

24+
job.start();
25+
26+
const __dirname = path.resolve();
2327
const app = express();
2428

2529
const httpServer = http.createServer(app);
@@ -74,8 +78,16 @@ app.use(
7478
})
7579
);
7680

81+
// npm run build will build your frontend app, and it will the optimized version of your app
82+
app.use(express.static(path.join(__dirname, "frontend/dist")));
83+
84+
app.get("*", (req, res) => {
85+
res.sendFile(path.join(__dirname, "frontend/dist", "index.html"));
86+
});
87+
88+
7789
// Modified server startup
78-
await new Promise((resolve) => httpServer.listen({ port: 8000 }, resolve));
90+
await new Promise((resolve) => httpServer.listen({ port: 4000 }, resolve));
7991
await connectDB();
8092

81-
console.log(`🚀 Server ready at http://localhost:8000/graphql`);
93+
console.log(`🚀 Server ready at http://localhost:4000/graphql`);

frontend/package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@tailwindcss/aspect-ratio": "^0.4.2",
1515
"chart.js": "^4.4.2",
1616
"clsx": "^2.1.0",
17+
"expense-tracker": "file:..",
1718
"framer-motion": "^11.0.28",
1819
"graphql": "^16.8.1",
1920
"mini-svg-data-uri": "^1.4.4",

package-lock.json

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"type": "module",
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
9-
"dev": "nodemon -r dotenv/config backend/index.js",
10-
"start": "node backend/index.js",
9+
"dev": "cross-env NODE_ENV=development nodemon -r dotenv/config backend/index.js",
10+
"start": "cross-env NODE_ENV=production node -r dotenv/config backend/index.js",
1111
"build": "npm install && npm install --prefix frontend && npm run build --prefix frontend"
1212
},
1313
"keywords": [],
1414
"author": "Amit Amrutiya",
1515
"license": "ISC",
1616
"devDependencies": {
17+
"cross-env": "^7.0.3",
1718
"dotenv": "^16.4.5",
1819
"nodemon": "^3.1.0"
1920
},
@@ -23,11 +24,13 @@
2324
"bcryptjs": "^2.4.3",
2425
"connect-mongodb-session": "^5.0.0",
2526
"cors": "^2.8.5",
27+
"cron": "^3.1.7",
2628
"express": "^4.19.2",
2729
"express-session": "^1.18.0",
2830
"graphql": "^16.8.1",
2931
"graphql-passport": "^0.6.8",
3032
"http": "^0.0.1-security",
33+
"https": "^1.0.0",
3134
"mongoose": "^8.3.1",
3235
"passport": "^0.7.0",
3336
"path": "^0.12.7"

0 commit comments

Comments
 (0)