telescope-sdk v1.0.0
Telescope Server Development Kit
This project is a work in progress.
How to use
You need to be a member of the BBC NPM organisation. To get access visit https://github.com/bbc/npm
Packages
TLS
A function to return TLS config using client cosmos certs
npm i @bbc/telescope-sdk-tls
import tls from '@bbc/telescope-sdk-tls';
import request from 'request';
request({
method: 'GET',
uri: '',
agentOptions: tls(),
}, (err, res, body) => {
// handle callback
});
Content Store
A class to retrieve data from the Content Store
npm i @bbc/telescope-sdk-content-store
import ContentStore from '@bbc/telescope-content-store';
const cs = new ContentStore({
key: 'APIKEY',
});
await cs.getAssetByCurie('curie');
await cs.getAssetByCPSID('id');
await cs.getAssetByUri('uri');
Creative Works
A class to retrieve data from Creative Works
npm i @bbc/telescope-sdk-creative-works
import CreativeWorks from '@bbc/telescope-creative-works';
const cs = new CreativeWorks({
key: 'APIKEY',
});
await cs.getTagByGuid('guid');
CreativeWorks.getTagByGuid('guid', { key: 'APIKEY' });
CPS
A class to retrieve the author of a piece of work
npm i @bbc/telescope-sdk-cps
import CPS from '@bbc/telescope-sdk-cps';
const cps = new CPS();
await cps.getByAssetId('assetid');
Redis
A helper class for our Redis implemnation
npm i @bbc/telescope-sdk-redis
import Redis from '@bbc/telescope-sdk-redis';
const redis =new Redis({
host: '0.0.0.0',
})
await redis.get('item');
Config
A helper function for gathering enviroment variables
npm i @bbc/telescope-sdk-config
import config from '@bbc/telescope-config';
const config = config();
Things
A class to retrieve data on a tag
npm i @bbc/telescope-sdk-things
import Thing from '@bbc/telescope-sdk-things';
const thing = new Thing({
key: 'API-KEY',
});
const res = thing.getTagByGuid('guid');
Pipeline
A class to handle a asyncronious tasks
npm i @bbc/telescope-sdk-pipeline
import Pipeline from '@bbc/telescope-sdk-pipeline';
const pipeline = new Pipeline({}, 'context');
pipeline(
func1,
func2,
func3,
func4,
);
Nitro
A class to handle retreiving video metadata. Accepts an eight character Programme ID.
npm i @bbc/telescope-sdk-nitro
import Nitro from '@bbc/telescope-sdk-nitro';
const nitro = new Nitro({
key: 'API-KEY',
});
const res = nitro.pid('pid');
SQS Parse
A helper function to parse SQS messages exposing the body of the payload
npm i @bbc/telescope-sdk-sqs-parse
const parsedMessage = sqsParse(sqsRawMessage);
Develop
Telescope-SDK uses Lerna, Jest and Typescript all of which need to be installed locally
Clone and install dependancies
To modify or create any services clone the repo
git clone https://github.com/bbc/telescope-sdk.git
npm i
Create a new package
If you need to create a new package, use Lerna to adminster the change from the root directory
lerna create {packagename}
Publish packages
Once you have finished creating or editing packages, create a pull request and merge into master. Your code should not not have any type any implicity and include 100% code coverages for tests
Once the PR has been merged, this will kick off a lerna publish
event which will reversion the packages and publish to NPM
Package laylout
Each package within the SDK could have a JEST config file, TSLint rules, TSconfig and a babel config.
root
-src (where your typescript lives)
-lib (where your typescript compiles to JS lives + exported typedefinitions)
-test (test director)
-package.json
-tsconfig.json
-jest.json
-.babelrc
Only commit the lib to your NPM package.
5 years ago