Skip to content

Commit a54ea15

Browse files
committed
フロントエンドとバックエンドの連携とデプロイの節を追加
1 parent cceb0dd commit a54ea15

29 files changed

+6624
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DATABASE_URL=""
2+
WEB_ORIGIN="http://localhost:5173"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules
2+
/.env
3+
/generated/prisma
4+
/dist
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import express from "express";
2+
import cors from "cors";
3+
import { PrismaClient } from "./generated/prisma/client.js";
4+
5+
const app = express();
6+
const client = new PrismaClient();
7+
8+
app.use(cors({ origin: process.env.WEB_ORIGIN }));
9+
app.use(express.json());
10+
11+
app.get("/posts", async (request, response) => {
12+
response.json(await client.post.findMany());
13+
});
14+
15+
app.post("/send", async (request, response) => {
16+
await client.post.create({ data: { message: request.body.message } });
17+
response.send();
18+
});
19+
20+
app.listen(3000);

0 commit comments

Comments
 (0)