2.6.4 • Published 4 years ago

acast-content-client v2.6.4

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Content-client

CircleCI

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:91fed7de2d643577c6bc944e195a368f@balin-eu-west-1.searchly.com");

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:91fed7de2d643577c6bc944e195a368f@balin-eu-west-1.searchly.com", "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).

PropertyPurpose
image_signatureIs a 40 character hexadecimal hash of the image url
image_signedThe 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

KeyPurposeValuesDefault
IMAGE_SIGN_KEYUsed to cryptographicly sign the urlAny string'i-like-cupcakes'
IMAGE_PROXY_URLThe base url for the proxy routeA valid URL + route'https://imagecdn.acast.com/imagesign'
LOG_QUERIESToggles logging of elastic searchesverboseempty = no logging
AZURE_SERVICEBUS_CONNECTION_STRINGThe service bus is used for logging searches
APP_NAMEWill be included in elastic logs
APP_REGIONWill be included in elastic logs

Categories codes

iTunes main categoriesAcast categories (codes)
Artsarts
Businessbusiness
Comedycomedy
Educationeducation
Games & Hobbieshobbies
Government & Organizationsgovorg
Healthhealth
Kids & Familyfamily
Musicmusic
News & Politicspolitics
Religion & Spiritualityreligion
Science & Medicinescience
Society & Culturesociety
Sports & Hobbies (Sports & Recreation)sports
Technologytechnology
TV & Filmfilm