Skip to content

Commit ec671b0

Browse files
committed
setup communication
1 parent eecd5eb commit ec671b0

File tree

10 files changed

+293
-112
lines changed

10 files changed

+293
-112
lines changed

backend/package-lock.json

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

backend/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
"type-check": "tsc --noemit"
77
},
88
"dependencies": {
9+
"@types/cors": "^2.8.17",
10+
"@types/express": "^4.17.21",
11+
"@types/node": "^20.12.13",
12+
"cors": "^2.8.5",
913
"dotenv": "^16.4.5",
1014
"express": "^4.19.2",
11-
"typescript": "^5.4.5",
12-
"@types/express": "^4.17.21",
13-
"@types/node": "^20.12.13"
15+
"typescript": "^5.4.5"
1416
},
1517
"devDependencies": {
1618
"nodemon": "^3.1.2",

backend/src/controllers/ping.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { RequestHandler } from "express";
2+
3+
export const PingHandler: RequestHandler = (req, res) => {
4+
res.status(200).send("Ping success!");
5+
}

backend/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import express, { Express } from "express";
2+
import cors from "cors";
23
import dotenv from "dotenv";
4+
import pingRoute from "./routes/ping";
35

46
dotenv.config();
57

68
const app: Express = express();
79
const port = process.env.PORT || 9000;
810

11+
// Middleware
12+
app.use(express.json());
13+
app.use(cors());
14+
15+
app.use(pingRoute);
16+
917
app.listen(port, () => {
1018
console.log(`Server successfully started on port ${port}`);
1119
});

backend/src/routes/ping.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Router } from "express";
2+
import { PingHandler } from "../controllers/ping";
3+
4+
const router = Router();
5+
6+
router.get("/ping", PingHandler);
7+
8+
export default router;

frontend/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ npm-debug.log
44
build
55
.git
66
*.md
7-
.gitignore
7+
.gitignore
8+
.env.local

frontend/.env.production

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### TODO: make private
2+
3+
# Backend
4+
NEXT_PUBLIC_BACKEND_HOST=localhost
5+
NEXT_PUBLIC_BACKEND_PORT=9000

0 commit comments

Comments
 (0)