acast-content-client
v2.6.4
Published
This is a npm module to read content from various places in our stack.
Downloads
3
Readme
Content-client
This is a npm package used to access content directly from the backend databases. It currently only supports elasticSearch but could support other datasources in the future.
It's a read-only api, so any writes need to be pushed to the servicebus using other services.
Some new additions
Check out how Content-client signes image urls!
##Usage
The client is initiated with the url to the elastic server as follows:
var elastic = Elastic("https://site:[email protected]");
It's also possible to pass a default value for the index so that you won't have to provide that for each call:
var elastic = Elastic("https://site:[email protected]", "content-alias");
The query format is as follows
var query = {
query: {
aProperty: "aValue"
},
skip: 10,
limit: 31
}
It's possible to include parent or child entities
var query = {
query: {
aProperty: "aValue"
},
includes: [
{
type: "bling",
relation: "child"
},
{
type: "channel",
relation: "parent"
}],
skip: 10,
limit: 31
}
If you only need a specific field you can use the fields property:
var query = {
query: {
aProperty: "aValue"
},
fields: ["name"]
}
It's possible to filter by multiple properties. Those are applied with logical OR:
var query = {
query: {
aProperty: ["aValue", "bValue"]
},
fields: ["name"]
}
NOTE: The query below isn't supported after a rewrite of the aggregations
(Now added support for nested includes
var query = {
query: {
aProperty: "aValue"
},
includes: [
{
type: "acast",
relation: "child",
includes: [
{
type: "bling",
relation: "child",
limit: 1000
}
]
}],
skip: 10,
limit: 31
}
) Word of caution for nested includes: The limit is per entity, so if you want all blings for a set of acasts you need to use a pretty high limit
Signed Image Urls
When there is a image property available there should also be a image_signature
and image_signed
property. The signing is done omitting query string parameters and protocol (http/https).
| Property | Purpose | |----------|---------| |image_signature| Is a 40 character hexadecimal hash of the image url | | image_signed | The whole address to the image via proxy and all |
Example of a bling image
{
duration: 30,
start: 1175,
type: 'com.acast.bling.iframe',
id: 'b37376ef-4337-4346-bf9b-2b298370bd85',
body: [Object],
image: 'https://acastprod.blob.core.windows.net:443/media/v1/b37376ef-4337-4346-bf9b-2b298370bd85/ska-rmavbild2015-11-20kl.09.44.37-ih7f835p.png',
description: 'Valerie Jerrett and President Obama ',
image_signed: 'https://imagecdn.acast.com/imagesign?source=https%3A%2F%2Facastprod.blob.core.windows.net%3A443%2Fmedia%2Fv1%2Fb37376ef-4337-4346-bf9b-2b298370bd85%2Fska-rmavbild2015-11-20kl.09.44.37-ih7f835p.png&sign=a83f5b00e4ccf3bc08f6205c72e53ec27923cccd',
image_signature: 'a83f5b00e4ccf3bc08f6205c72e53ec27923cccd'
}
Config
| Key | Purpose | Values | Default | |-----|---------|--------|---------| | IMAGE_SIGN_KEY | Used to cryptographicly sign the url | Any string | 'i-like-cupcakes' | | IMAGE_PROXY_URL | The base url for the proxy route | A valid URL + route | 'https://imagecdn.acast.com/imagesign' | |LOG_QUERIES|Toggles logging of elastic searches|verbose|empty = no logging| |AZURE_SERVICEBUS_CONNECTION_STRING|The service bus is used for logging searches| | | |APP_NAME|Will be included in elastic logs| | | |APP_REGION|Will be included in elastic logs| | |
Categories codes
|iTunes main categories|Acast categories (codes)| |-----|---------|--------|---------| |Arts| arts| |Business| business| |Comedy| comedy| |Education| education| |Games & Hobbies| hobbies| |Government & Organizations| govorg| |Health| health| |Kids & Family| family| |Music| music| |News & Politics| politics| |Religion & Spirituality| religion| |Science & Medicine| science| |Society & Culture| society| |Sports & Hobbies (Sports & Recreation)| sports| |Technology| technology| |TV & Film| film|