Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Motion Bank
Services
Motion Bank API
Commits
f604147c
Commit
f604147c
authored
Jul 04, 2018
by
A. Koch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated resources and acl stuff
parent
e99679cf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
3 deletions
+81
-3
bin/import.js
bin/import.js
+41
-0
package-lock.json
package-lock.json
+31
-0
package.json
package.json
+1
-0
src/acl.js
src/acl.js
+1
-0
src/index.js
src/index.js
+6
-2
src/service.js
src/service.js
+1
-1
No files found.
bin/import.js
0 → 100644
View file @
f604147c
const
path
=
require
(
'
path
'
),
fs
=
require
(
'
mz/fs
'
),
{
MongoDB
}
=
require
(
'
mbjs-persistence
'
),
{
ObjectUtil
}
=
require
(
'
mbjs-utils
'
),
config
=
require
(
'
config
'
)
const
folder
=
process
.
env
.
FOLDER
if
(
!
folder
)
throw
new
Error
(
'
no input folder specified
'
)
const
proc
=
async
function
(
folder
)
{
const
mapsClient
=
new
MongoDB
(
ObjectUtil
.
merge
({
name
:
'
maps
'
,
logger
:
console
},
config
.
get
(
'
resources.mongodb
'
)),
'
uuid
'
)
await
mapsClient
.
connect
()
const
maps
=
await
fs
.
readdir
(
path
.
join
(
folder
,
'
maps
'
))
for
(
let
m
of
maps
)
{
const
file
=
await
fs
.
readFile
(
path
.
join
(
folder
,
'
maps
'
,
m
))
const
entry
=
JSON
.
parse
(
file
)
await
mapsClient
.
create
(
entry
)
}
const
annoClient
=
new
MongoDB
(
ObjectUtil
.
merge
({
name
:
'
annotations
'
,
logger
:
console
},
config
.
get
(
'
resources.mongodb
'
)),
'
uuid
'
)
await
annoClient
.
connect
()
const
annos
=
await
fs
.
readdir
(
path
.
join
(
folder
,
'
annotations
'
))
for
(
let
a
of
annos
)
{
const
file
=
await
fs
.
readFile
(
path
.
join
(
folder
,
'
annotations
'
,
a
))
const
entry
=
JSON
.
parse
(
file
)
await
annoClient
.
create
(
entry
)
}
}
proc
(
folder
)
.
then
(()
=>
process
.
exit
(
0
))
package-lock.json
View file @
f604147c
...
...
@@ -339,6 +339,11 @@
"color-convert"
:
"^1.9.0"
}
},
"any-promise"
:
{
"version"
:
"1.3.0"
,
"resolved"
:
"https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz"
,
"integrity"
:
"sha1-q8av7tzqUugJzcA3au0845Y10X8="
},
"argparse"
:
{
"version"
:
"1.0.10"
,
"resolved"
:
"https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz"
,
...
...
@@ -2253,6 +2258,16 @@
"integrity"
:
"sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s="
,
"dev"
:
true
},
"mz"
:
{
"version"
:
"2.7.0"
,
"resolved"
:
"https://registry.npmjs.org/mz/-/mz-2.7.0.tgz"
,
"integrity"
:
"sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q=="
,
"requires"
:
{
"any-promise"
:
"^1.0.0"
,
"object-assign"
:
"^4.0.1"
,
"thenify-all"
:
"^1.0.0"
}
},
"nan"
:
{
"version"
:
"2.10.0"
,
"resolved"
:
"https://registry.npmjs.org/nan/-/nan-2.10.0.tgz"
,
...
...
@@ -3095,6 +3110,22 @@
"integrity"
:
"sha1-f17oI66AUgfACvLfSoTsP8+lcLQ="
,
"dev"
:
true
},
"thenify"
:
{
"version"
:
"3.3.0"
,
"resolved"
:
"https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz"
,
"integrity"
:
"sha1-5p44obq+lpsBCCB5eLn2K4hgSDk="
,
"requires"
:
{
"any-promise"
:
"^1.0.0"
}
},
"thenify-all"
:
{
"version"
:
"1.6.0"
,
"resolved"
:
"https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz"
,
"integrity"
:
"sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY="
,
"requires"
:
{
"thenify"
:
">= 3.1.0 < 4"
}
},
"through"
:
{
"version"
:
"2.3.8"
,
"resolved"
:
"https://registry.npmjs.org/through/-/through-2.3.8.tgz"
,
...
...
package.json
View file @
f604147c
...
...
@@ -40,6 +40,7 @@
"
mbjs-utils
"
:
"
0.0.5
"
,
"
mongodb
"
:
"
^3.1.0
"
,
"
morgan
"
:
"
^1.9.0
"
,
"
mz
"
:
"
^2.7.0
"
,
"
nedb
"
:
"
^1.8.0
"
,
"
polka
"
:
"
^0.4.0
"
,
"
primus
"
:
"
^7.2.2
"
,
...
...
src/acl.js
View file @
f604147c
...
...
@@ -6,6 +6,7 @@ const
const
setupACL
=
async
function
(
app
)
{
const
cfg
=
config
.
get
(
'
acl.mongodb
'
)
cfg
.
logger
=
console
const
client
=
new
MongoDB
(
cfg
,
'
uuid
'
)
await
client
.
connect
()
const
acl
=
new
Acl
(
new
Backend
(
client
.
db
,
cfg
.
prefix
))
...
...
src/index.js
View file @
f604147c
...
...
@@ -75,7 +75,11 @@ const setup = async function () {
/**
* Start server
*/
app
.
listen
(
port
,
host
).
then
(()
=>
winston
.
log
(
'
info
'
,
`API started on
${
host
}
:
${
port
}
`
))
return
app
.
listen
(
port
,
host
).
then
(()
=>
winston
.
log
(
'
info
'
,
`API started on
${
host
}
:
${
port
}
`
))
}
setup
()
setup
().
catch
(
err
=>
{
process
.
stderr
.
write
(
err
.
message
+
'
\n
'
)
process
.
stderr
.
write
(
err
.
stack
+
'
\n
'
)
process
.
exit
(
err
.
code
)
})
src/service.js
View file @
f604147c
...
...
@@ -19,7 +19,7 @@ class Service extends TinyEmitter {
app
.
get
(
`/
${
this
.
_name
}
`
,
async
(
req
,
res
)
=>
{
const
results
=
await
this
.
client
.
find
(
req
.
params
.
query
||
{},
req
.
params
)
_this
.
_response
(
req
,
res
,
results
)
_this
.
_response
(
req
,
res
,
{
items
:
results
}
)
})
app
.
get
(
`/
${
this
.
_name
}
/:id`
,
async
(
req
,
res
)
=>
{
...
...
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