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
7c05c757
Commit
7c05c757
authored
Dec 12, 2017
by
Evgeniy Zaitsev
Browse files
v1.1.0
parent
8c4650c5
Changes
3
Show whitespace changes
Inline
Side-by-side
lib/createTables.js
View file @
7c05c757
'
use strict
'
;
function
*
createTables
()
{
function
*
createTables
()
{
try
{
yield
this
.
db
.
queryAsync
(
`
yield
this
.
db
.
queryAsync
(
`
CREATE TABLE IF NOT EXISTS
\`
${
this
.
config
.
mySql
.
database
}
\`
.
\`
${
this
.
tablesNames
.
INSTANCES
}
\`
(
\`
id
\`
CHAR(36) NOT NULL,
\`
name
\`
CHAR(255) NOT NULL,
...
...
@@ -12,11 +13,11 @@ function* createTables() {
PRIMARY KEY (
\`
id
\`
),
UNIQUE INDEX
\`
id_UNIQUE
\`
(
\`
id
\`
ASC)
)
`
);
`
);
yield
this
.
db
.
queryAsync
(
`
yield
this
.
db
.
queryAsync
(
`
CREATE TABLE IF NOT EXISTS
\`
${
this
.
config
.
mySql
.
database
}
\`
.
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
(
\`
id
\`
CHAR(36) NOT NULL,
\`
name
\`
CHAR(255) NOT NULL,
...
...
@@ -25,12 +26,22 @@ function* createTables() {
PRIMARY KEY (
\`
id
\`
),
UNIQUE INDEX
\`
id_UNIQUE
\`
(
\`
id
\`
ASC)
)
`
);
`
);
yield
this
.
db
.
queryAsync
(
`
ALTER TABLE
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
ADD
\`
project_id
\`
MEDIUMINT
`
);
this
.
logger
.
log
(
__filename
,
'
tables created successfully
'
);
this
.
logger
.
log
(
__filename
,
'
tables created successfully
'
);
}
catch
(
err
)
{
this
.
logger
.
error
(
err
);
this
.
logger
.
error
(
err
);
throw
err
;
}
...
...
package.json
View file @
7c05c757
{
"name"
:
"service-sdk"
,
"version"
:
"1.
0.6
"
,
"version"
:
"1.
1.0
"
,
"private"
:
true
,
"description"
:
"Service SDK for LViS"
,
"keywords"
:
[],
...
...
router/project.js
View file @
7c05c757
...
...
@@ -3,9 +3,12 @@
function
*
post
()
{
const
project
=
{
id
:
this
.
checkBody
(
'
project_uuid
'
).
isUUID
().
value
,
name
:
this
.
checkBody
(
'
project_name
'
).
notBlank
().
isLength
(
1
,
255
).
value
,
feed_uuid
:
this
.
checkBody
(
'
feed_uuid
'
).
isUUID
().
value
,
name
:
this
.
checkBody
(
'
project_name
'
)
.
notBlank
()
.
isLength
(
1
,
255
).
value
,
config
:
this
.
checkBody
(
'
config
'
).
eq
(
'
[object Object]
'
).
value
,
feed_uuid
:
this
.
checkBody
(
'
feed_uuid
'
).
isUUID
().
value
,
project_id
:
this
.
checkBody
(
'
project_id
'
).
isInt
().
value
,
};
const
str
=
JSON
.
stringify
(
project
);
...
...
@@ -20,8 +23,10 @@ function* post() {
if
(
projects
.
length
)
{
yield
this
.
db
.
queryAsync
(
`UPDATE
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
SET name = ?, feed_uuid = ?, config = ? WHERE id = ?`
,
[
project
.
name
,
project
.
feed_uuid
,
project
.
config
,
project
.
id
]
`UPDATE
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
SET name = ?, feed_uuid = ?, project_id = ?, config = ? WHERE id = ?`
,
[
project
.
name
,
project
.
feed_uuid
,
project
.
project_id
,
project
.
config
,
project
.
id
]
);
this
.
logger
.
log
(
...
...
@@ -50,7 +55,9 @@ function* post() {
function
*
put
()
{
const
project
=
{
name
:
this
.
checkBody
(
'
project_name
'
).
notBlank
().
isLength
(
1
,
255
).
value
,
name
:
this
.
checkBody
(
'
project_name
'
)
.
notBlank
()
.
isLength
(
1
,
255
).
value
,
config
:
this
.
checkBody
(
'
config
'
).
eq
(
'
[object Object]
'
).
value
,
};
const
str
=
JSON
.
stringify
(
project
);
...
...
@@ -61,11 +68,10 @@ function* put() {
project
.
config
=
JSON
.
stringify
(
project
.
config
);
yield
this
.
db
.
queryAsync
(
`UPDATE
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
SET name = ?, config = ? WHERE id = ?`
,
[
project
.
name
,
project
.
config
,
this
.
state
.
project
.
id
,
]);
yield
this
.
db
.
queryAsync
(
`UPDATE
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
SET name = ?, config = ? WHERE id = ?`
,
[
project
.
name
,
project
.
config
,
this
.
state
.
project
.
id
]
);
this
.
logger
.
log
(
__filename
,
...
...
@@ -82,7 +88,9 @@ function* put() {
function
*
del
()
{
this
.
logger
.
log
(
__filename
,
'
DELETE
'
);
yield
this
.
db
.
queryAsync
(
`DELETE FROM
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
WHERE id = ?`
,
[
this
.
state
.
project
.
id
]);
yield
this
.
db
.
queryAsync
(
`DELETE FROM
\`
${
this
.
tablesNames
.
PROJECTS
}
\`
WHERE id = ?`
,
[
this
.
state
.
project
.
id
,
]);
this
.
logger
.
log
(
__filename
,
...
...
@@ -96,4 +104,4 @@ function* del() {
this
.
body
=
{};
}
module
.
exports
=
{
post
,
put
,
del
};
module
.
exports
=
{
post
,
put
,
del
};
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