Toggle navigation
Toggle navigation
This project
Loading...
Sign in
201side
/
floater
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
ivoire5204
2020-12-09 20:24:25 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b9748d1944564033be16e9a248aea2ddca33e3f2
b9748d19
1 parent
92d36ed2
Builds for 1 pipeline
failed
in 0 seconds
app.post 수정
Changes
1
Builds
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletions
src/routes/board.js
src/routes/board.js
View file @
b9748d1
...
...
@@ -13,8 +13,9 @@ app.get('/board/:bid', async(req, res) => {
res
.
render
(
'threadslist'
,
{
board
,
threads
});
});
/*
app.post('/board/:bid/thread', async(req, res) => {
if
(
!
req
.
body
.
title
||
!
req
.
body
.
content
)
{
if(!req.body.title || !req.body.content) {
//
res.status(400).json({error: 'Invalid input'});
}
let board = await db.get('board').findOne({name: req.params.bid});
...
...
@@ -24,6 +25,21 @@ app.post('/board/:bid/thread', async(req, res) => {
let thread = await db.get('thread').insert({board: board._id, title: req.body.title, content: req.body.content, lastUpdated: Date.now(), count: 1});
res.json({thread});
});
*/
app
.
post
(
'/board/:bid'
,
async
(
req
,
res
)
=>
{
if
(
!
req
.
body
.
title
||
!
req
.
body
.
content
)
{
res
.
status
(
400
).
send
(
'제목이나 내용을 써주세요.'
);
return
;
}
let
board
=
await
db
.
get
(
'board'
).
findOne
({
name
:
req
.
params
.
bid
});
if
(
!
board
)
{
res
.
status
(
404
).
send
(
'그런 판은 우리에게 있을 수 없어.'
);
}
let
thread
=
await
db
.
get
(
'thread'
).
insert
({
board
:
board
.
_id
,
title
:
req
.
body
.
title
,
content
:
req
.
body
.
content
,
lastUpdated
:
Date
.
now
(),
count
:
1
});
res
.
redirect
(
'/thread/'
+
thread
.
insertedIds
);
});
app
.
get
(
'/borad/:bid/thread/:tid'
,
async
(
req
,
res
)
=>
{
let
thread
=
await
db
.
get
(
'thread'
).
findOne
(
req
.
params
.
tid
);
if
(
!
thread
)
{
...
...
Please
register
or
login
to post a comment