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
1ac7c40a
Commit
1ac7c40a
authored
May 10, 2019
by
Anton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add PBA endpoints, update changelog
parent
5d6334ee
Pipeline
#10780
passed with stage
in 12 minutes and 7 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
0 deletions
+79
-0
CHANGELOG.md
CHANGELOG.md
+4
-0
config/custom-environment-variables.json
config/custom-environment-variables.json
+7
-0
config/default.json
config/default.json
+7
-0
config/dev.json
config/dev.json
+7
-0
src/index.js
src/index.js
+8
-0
src/lib/pba.js
src/lib/pba.js
+46
-0
No files found.
CHANGELOG.md
View file @
1ac7c40a
...
...
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
-
Basic
[
Pina Bausch Archive (PBA)
](
http://www.pinabausch.org
)
proxy endpoints for pieces and titles
### Updated
-
Updated
[
mbjs-data-models
](
https://gitlab.rlp.net/motionbank/mbjs/data-models
)
...
...
config/custom-environment-variables.json
View file @
1ac7c40a
...
...
@@ -55,5 +55,12 @@
"jwt"
:
{
"audience"
:
"AUTH0_AUDIENCE"
}
},
"pba"
:
{
"baseUrl"
:
"PBA_BASE_URL"
,
"credentials"
:
{
"username"
:
"PBA_USERNAME"
,
"password"
:
"PBA_PASSWORD"
}
}
}
config/default.json
View file @
1ac7c40a
...
...
@@ -66,5 +66,12 @@
"apiKeys"
:
{
"youtube"
:
null
,
"vimeo"
:
null
},
"pba"
:
{
"baseUrl"
:
null
,
"credentials"
:
{
"username"
:
null
,
"password"
:
null
}
}
}
config/dev.json
View file @
1ac7c40a
...
...
@@ -64,5 +64,12 @@
"apiKeys"
:
{
"youtube"
:
null
,
"vimeo"
:
null
},
"pba"
:
{
"baseUrl"
:
null
,
"credentials"
:
{
"username"
:
null
,
"password"
:
null
}
}
}
src/index.js
View file @
1ac7c40a
...
...
@@ -52,6 +52,14 @@ const setup = async function () {
const
archives
=
require
(
'
./lib/archives
'
)
archives
.
setupArchives
(
api
,
maps
,
annotations
,
cells
)
/**
* Configure PBA
*/
const
PBA
=
require
(
'
./lib/pba
'
),
pba
=
new
PBA
(
api
)
await
api
.
start
()
}
...
...
src/lib/pba.js
0 → 100644
View file @
1ac7c40a
const
config
=
require
(
'
config
'
),
send
=
require
(
'
@polka/send-type
'
),
TinyEmitter
=
require
(
'
tiny-emitter
'
),
axios
=
require
(
'
axios
'
)
class
PBA
extends
TinyEmitter
{
constructor
(
api
)
{
super
()
const
_this
=
this
api
.
app
.
get
(
'
/pba/pieces
'
,
(
req
,
res
)
=>
_this
.
getPiecesHandler
(
req
,
res
))
api
.
app
.
get
(
'
/pba/pieces/:piece_id/titles
'
,
(
req
,
res
)
=>
_this
.
getTitlesForPieceHandler
(
req
,
res
))
}
async
_performRequest
(
path
)
{
const
result
=
await
axios
.
get
(
`
${
config
.
pba
.
baseUrl
}
/
${
path
}
`
,
{
auth
:
config
.
pba
.
credentials
})
return
result
.
data
}
async
getPiecesHandler
(
req
,
res
)
{
const
result
=
await
this
.
_performRequest
(
'
pieces
'
)
this
.
_response
(
req
,
res
,
result
.
pieces
)
}
async
getTitlesForPieceHandler
(
req
,
res
)
{
const
result
=
await
this
.
_performRequest
(
`titles/
${
req
.
params
.
piece_id
}
`
)
this
.
_response
(
req
,
res
,
result
.
titles
)
}
_response
(
req
,
res
,
data
=
{})
{
this
.
emit
(
'
message
'
,
{
method
:
req
.
method
,
id
:
data
.
id
})
if
(
typeof
res
===
'
function
'
)
res
({
data
})
else
if
(
typeof
res
===
'
undefined
'
)
return
Promise
.
resolve
({
data
})
else
send
(
res
,
200
,
data
)
}
_errorResponse
(
res
,
code
,
message
=
undefined
)
{
if
(
typeof
res
===
'
function
'
)
res
({
error
:
true
,
code
})
else
if
(
typeof
res
===
'
undefined
'
)
return
Promise
.
resolve
({
error
:
true
,
code
})
else
send
(
res
,
code
,
message
)
}
}
module
.
exports
=
PBA
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