Skip to content

Commit 28be016

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

32 files changed

+6645
-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+
app.use(express.json());
8+
app.use(cors({ origin: process.env.WEB_ORIGIN }));
9+
10+
app.get("/posts", async (request, response) => {
11+
const posts = await client.post.findMany();
12+
response.json(posts);
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)