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-tlsimport 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-storeimport 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-worksimport 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-cpsimport 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-redisimport 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-configimport config from '@bbc/telescope-config';
const config = config();Things
A class to retrieve data on a tag
npm i @bbc/telescope-sdk-thingsimport 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-pipelineimport 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-nitroimport 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-parseconst 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 iCreate 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.
7 years ago