Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
storage-mongo-node
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
microservices
storage-mongo-node
Commits
fa98e12d
Commit
fa98e12d
authored
Feb 18, 2018
by
Vadym Gidulian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed premature closing of connection
parent
2d6f79b9
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
package.json
package.json
+1
-1
index.js
src/index.js
+13
-1
No files found.
package.json
View file @
fa98e12d
{
"name"
:
"storage-mongo-node"
,
"version"
:
"1.0.
0
"
,
"version"
:
"1.0.
1
"
,
"dependencies"
:
{
"
express
"
:
"
^4.16.2
"
,
...
...
src/index.js
View file @
fa98e12d
...
...
@@ -39,6 +39,8 @@ app.post('/:collection', (req, res) => {
const
record
=
result
.
ops
[
0
];
res
.
status
(
201
).
append
(
'Location'
,
`/
${
req
.
params
.
collection
}
/
${
record
.
_id
}
`
).
send
(
record
);
client
.
close
();
});
});
});
...
...
@@ -55,6 +57,7 @@ app.put('/:collection/:id', (req, res) => {
if
(
result
)
{
res
.
status
(
409
).
send
(
`Record with key
${
req
.
params
.
id
}
already exists`
);
client
.
close
();
return
;
}
...
...
@@ -63,6 +66,8 @@ app.put('/:collection/:id', (req, res) => {
const
record
=
result
.
ops
[
0
];
res
.
status
(
201
).
append
(
'Location'
,
`/
${
req
.
params
.
collection
}
/
${
record
.
_id
}
`
).
send
(
record
);
client
.
close
();
});
});
});
...
...
@@ -73,6 +78,8 @@ app.get('/:collection', (req, res) => {
if
(
err
)
throw
err
;
res
.
status
(
200
).
send
(
result
);
client
.
close
();
});
});
});
...
...
@@ -86,6 +93,8 @@ app.get('/:collection/:id', (req, res) => {
}
else
{
res
.
status
(
404
).
send
();
}
client
.
close
();
});
});
});
...
...
@@ -105,6 +114,8 @@ app.patch('/:collection/:id', (req, res) => {
}
else
{
res
.
status
(
404
).
send
();
}
client
.
close
();
});
});
});
...
...
@@ -118,6 +129,8 @@ app.delete('/:collection/:id', (req, res) => {
}
else
{
res
.
status
(
404
).
send
();
}
client
.
close
();
});
});
});
...
...
@@ -143,7 +156,6 @@ function mongoSafeConnect(serverResponse, callback) {
}
catch
(
e
)
{
console
.
log
(
e
);
serverResponse
.
status
(
500
).
send
();
}
finally
{
if
(
client
)
client
.
close
();
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment