Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
publics
service-sdk-releases
Commits
a0121eb9
Commit
a0121eb9
authored
Oct 18, 2016
by
Evgeniy Zaitsev
Browse files
v0.0.16
parent
6525a250
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
a0121eb9
{
"name"
:
"service-sdk"
,
"version"
:
"0.0.1
5
"
,
"version"
:
"0.0.1
6
"
,
"private"
:
true
,
"description"
:
"Service SDK for LViS"
,
"keywords"
:
[],
...
...
router/lvis.js
View file @
a0121eb9
'
use strict
'
;
function
*
post
()
{
cons
t
instance
=
{
le
t
instance
=
{
id
:
this
.
checkBody
(
'
id
'
).
isUUID
().
value
,
name
:
this
.
checkBody
(
'
name
'
).
notBlank
().
isLength
(
1
,
255
).
value
,
auth_endpoint
:
this
.
checkBody
(
'
auth_endpoint
'
).
isUrl
().
isLength
(
1
,
255
).
value
,
...
...
@@ -13,13 +13,32 @@ function * post() {
this
.
throwResponseErrorIfNeed
(
this
.
errors
);
yield
this
.
db
.
queryAsync
(
`INSERT INTO
\`
${
this
.
tablesNames
.
INSTANCES
}
\`
SET ?`
,
instance
);
const
selectQuery
=
`SELECT * FROM
\`
${
this
.
tablesNames
.
INSTANCES
}
\`
WHERE
\`
id
\`
= "
${[
instance
.
id
]}
"`
;
const
oldInstances
=
yield
this
.
db
.
queryAsync
(
selectQuery
);
const
oldInstance
=
oldInstances
[
0
];
this
.
logger
.
log
(
__filename
,
'
inserted instance with id
'
,
instance
.
id
,
'
to table
'
,
this
.
tablesNames
.
INSTANCES
,
'
successfully
'
);
if
(
oldInstance
)
{
instance
=
Object
.
assign
({},
oldInstance
,
instance
);
yield
this
.
db
.
queryAsync
(
`UPDATE
\`
${
this
.
tablesNames
.
INSTANCES
}
\`
SET name = ?, auth_endpoint = ?, feed_endpoint = ? WHERE id = ?`
,
[
instance
.
name
,
instance
.
auth_endpoint
,
instance
.
feed_endpoint
,
instance
.
id
]
);
this
.
logger
.
log
(
__filename
,
'
updated instance with id
'
,
instance
.
id
,
'
in table
'
,
this
.
tablesNames
.
INSTANCES
,
'
successfully
'
);
}
else
{
yield
this
.
db
.
queryAsync
(
`INSERT INTO
\`
${
this
.
tablesNames
.
INSTANCES
}
\`
SET ?`
,
instance
);
this
.
logger
.
log
(
__filename
,
'
inserted instance with id
'
,
instance
.
id
,
'
to table
'
,
this
.
tablesNames
.
INSTANCES
,
'
successfully
'
);
}
this
.
body
=
{
service_id
:
this
.
config
.
service
.
id
,
...
...
Write
Preview
Supports
Markdown
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