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
robin*
2020-12-10 12:10:26 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
db6864909a0fc94f9abdfc24cbedca5d0a6f8864
db686490
1 parent
de9bb940
Builds for 1 pipeline
failed
in 0 seconds
리버스프록시 뒤에 있어도 제 ip를 사용하도록 수정
Changes
3
Builds
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
2 deletions
src/main.js
src/routes/board.js
src/socket.js
src/main.js
View file @
db68649
...
...
@@ -21,6 +21,7 @@ const hbs = exphbs.create({
app
.
engine
(
'handlebars'
,
hbs
.
engine
);
app
.
set
(
'view engine'
,
'handlebars'
);
app
.
set
(
'views'
,
path
.
join
(
__dirname
,
'views'
));
app
.
set
(
'trust proxy'
,
true
);
fs
.
readdirSync
(
path
.
resolve
(
__dirname
,
'routes'
)).
forEach
((
name
)
=>
{
require
(
path
.
resolve
(
__dirname
,
'routes'
,
name
));
...
...
src/routes/board.js
View file @
db68649
...
...
@@ -24,6 +24,6 @@ app.post('/board/:bid', async(req, res) => {
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
});
await
db
.
get
(
'thread'
).
update
(
thread
.
_id
,
{
$set
:
{
writer
:
hash
(
thread
.
_id
,
req
.
ip
)}});
await
db
.
get
(
'thread'
).
update
(
thread
.
_id
,
{
$set
:
{
writer
:
hash
(
thread
.
_id
,
req
.
get
(
'x-real-ip'
)
||
req
.
ip
)}});
res
.
redirect
(
'/thread/'
+
thread
.
_id
);
});
...
...
src/socket.js
View file @
db68649
...
...
@@ -22,7 +22,7 @@ module.exports = {
});
socket
.
on
(
'write'
,
async
(
content
)
=>
{
console
.
log
(
`write
${
content
}
`
);
let
subthread
=
await
db
.
get
(
'subthread'
).
insert
({
parent
:
thread
.
_id
,
writer
:
hash
(
thread
.
_id
,
socket
.
handshake
.
address
),
content
,
no
:
++
thread
.
count
});
let
subthread
=
await
db
.
get
(
'subthread'
).
insert
({
parent
:
thread
.
_id
,
writer
:
hash
(
thread
.
_id
,
socket
.
handshake
.
headers
[
'x-real-ip'
]
||
socket
.
handshake
.
address
),
content
,
no
:
++
thread
.
count
});
db
.
get
(
'thread'
).
update
(
thread
.
_id
,
{
$set
:
{
count
:
thread
.
count
,
lastUpdated
:
Date
.
now
()}});
io
.
to
(
`thread-
${
thread
.
_id
}
`
).
emit
(
'thread'
,
subthread
);
console
.
log
(
`broadcast thread-
${
thread
.
_id
}
`
);
...
...
Please
register
or
login
to post a comment