Commit a0121eb9 authored by Evgeniy Zaitsev's avatar Evgeniy Zaitsev
Browse files

v0.0.16

parent 6525a250
{
"name": "service-sdk",
"version": "0.0.15",
"version": "0.0.16",
"private": true,
"description": "Service SDK for LViS",
"keywords": [],
......
'use strict';
function * post() {
const instance = {
let 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,6 +13,24 @@ function * post() {
this.throwResponseErrorIfNeed(this.errors);
const selectQuery = `SELECT * FROM \`${this.tablesNames.INSTANCES}\` WHERE \`id\` = "${[instance.id]}"`;
const oldInstances = yield this.db.queryAsync(selectQuery);
const oldInstance = oldInstances[0];
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,
......@@ -20,6 +38,7 @@ function * post() {
'to table', this.tablesNames.INSTANCES,
'successfully'
);
}
this.body = {
service_id: this.config.service.id,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment