Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정민우
/
vps_service
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정민우
2021-06-10 23:53:32 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
08dde729f076913e467c692f0422293696ff1abe
08dde729
1 parent
90db42a3
[Edit] dockerfile add 예외처리
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
backend/controllers/dockerController.js
backend/controllers/dockerController.js
View file @
08dde72
...
...
@@ -19,21 +19,27 @@ exports.addDockerfile = async (req, res) => {
logging
(
'dockerfile'
,
'error'
,
{
code
:
400
,
message
:
`missingKey:
${
required
}
`
},
req
)
return
sendError
(
res
,
400
,
`missingKey:
${
required
}
`
)
}
let
dockerfileInfo
=
{}
dockerfileInfo
.
userId
=
id
dockerfileInfo
.
content
=
req
.
body
.
content
let
dockerfileDir
=
randomstring
.
generate
(
16
);
fs
.
mkdirSync
(
'./dockerfiles/'
+
dockerfileDir
)
dockerfileInfo
.
filepath
=
'./dockerfiles/'
+
dockerfileDir
+
'/Dockerfile'
fs
.
writeFile
(
dockerfileInfo
.
filepath
,
dockerfileInfo
.
content
,
function
(
err
)
{
if
(
err
)
{
logging
(
'dockerfile'
,
'error'
,
{
code
:
400
,
message
:
`dockerfile write error`
},
req
)
return
sendError
(
res
,
400
,
`dockerfile write error`
)
}
})
let
user
=
await
Dockerfile
.
create
(
dockerfileInfo
)
logging
(
'dockerfile'
,
'add dockerfile'
,
user
,
req
)
return
sendResponse
(
res
,
user
,
200
)
try
{
let
dockerfileInfo
=
{}
dockerfileInfo
.
userId
=
id
dockerfileInfo
.
content
=
req
.
body
.
content
let
dockerfileDir
=
randomstring
.
generate
(
16
);
fs
.
mkdirSync
(
'./dockerfiles/'
+
dockerfileDir
)
dockerfileInfo
.
filepath
=
'./dockerfiles/'
+
dockerfileDir
+
'/Dockerfile'
fs
.
writeFile
(
dockerfileInfo
.
filepath
,
dockerfileInfo
.
content
,
function
(
err
)
{
if
(
err
)
{
logging
(
'dockerfile'
,
'error'
,
{
code
:
400
,
message
:
`dockerfile write error`
},
req
)
return
sendError
(
res
,
400
,
`dockerfile write error`
)
}
})
let
user
=
await
Dockerfile
.
create
(
dockerfileInfo
)
logging
(
'dockerfile'
,
'add dockerfile'
,
user
,
req
)
return
sendResponse
(
res
,
user
,
200
)
}
catch
(
error
)
{
logging
(
'dockerfile'
,
'error'
,
{
code
:
500
,
message
:
error
.
message
},
req
)
return
sendError
(
res
,
500
,
error
.
message
)
}
}
exports
.
listDockerfile
=
async
(
req
,
res
)
=>
{
...
...
Please
register
or
login
to post a comment