Skip to content

Commit b8ede56

Browse files
Merge pull request #21 from condinoaljoseph/feature/rewrite
Feature/rewrite
2 parents 53e9a56 + 9455751 commit b8ede56

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Social media hub for devs. See wireframe [here](https://www.figma.com/proto/j5k2HwZo4xUldyprIF7Jzw/DevCommunity?node-id=1%3A2&viewport=783%2C335%2C0.7666961550712585&scaling=min-zoom)
44

55
### feature plans
6+
67
- can add snippets and blog
78
- can generate styled snippets (ie crawling carbon.now.sh to generate image snippets)
89
- github oath with next-auth
@@ -19,3 +20,23 @@ Social media hub for devs. See wireframe [here](https://www.figma.com/proto/j5k2
1920

2021
- [Heroku](https://www.heroku.com/)
2122
- [Vercel](https://vercel.com/)
23+
24+
### how to contribute
25+
26+
Install all dependency
27+
28+
```bash
29+
npm install
30+
```
31+
32+
Run the command to open Prisma Studio's interface
33+
34+
```bash
35+
npx prisma studio
36+
```
37+
38+
Run on development mode on your local machine
39+
40+
```bash
41+
npm run dev
42+
```

package-lock.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"next": "^10.2.0",
1818
"next-auth": "^3.7.1",
1919
"react": "17.0.1",
20-
"react-dom": "17.0.1"
20+
"react-dom": "17.0.1",
21+
"swr": "^0.5.6"
2122
},
2223
"devDependencies": {
2324
"@types/next-auth": "^3.5.1",

pages/api/post/index.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { NextApiRequest, NextApiResponse } from 'next';
2+
import { getSession } from 'next-auth/client';
3+
import prisma from '@/lib/prisma';
4+
5+
// POST /api/post
6+
// Required fields in body: title
7+
// Optional fields in body: content
8+
9+
export default async function handler(
10+
req: NextApiRequest,
11+
res: NextApiResponse
12+
) {
13+
const { title, content } = req.body;
14+
15+
const session = await getSession({ req });
16+
const result = await prisma.post.create({
17+
data: {
18+
title,
19+
content,
20+
author: { connect: { email: session?.user?.email } }
21+
}
22+
});
23+
24+
res.json(result);
25+
}

0 commit comments

Comments
 (0)