Giter Site home page Giter Site logo

kenticoclouddeliverytypescriptsdk's Introduction

Kentico Cloud Delivery JavaScript / TypeScript SDK

npm version Build Status npm Forums Coverage Status Known Vulnerabilities Dependency Status

A client library for retrieving content from Kentico Cloud that supports JavaScript and TypeScript.

TypeScript

JavaScript

DocumentationDocumentation
Quick startQuick start
Sample apps
JavaScript appAngular 4 app
API documentation
Get items (Observable)Get items (Observable)
Get items (Promise)Get items (Promise)
Creating modelsCreating models
Model generatorModel generator
Initialize clientInitialize client
Query parametersQuery parameters
FilteringFiltering
SortingSorting
LocalizationLocalization
Property binding / Model decoratorsProperty binding
Preview modePreview mode
URL slugsURL slugs
Rich text resolverRich text resolver
Strongly typed nested propertyN/A
Get typesGet types
Get taxonomiesGet taxonomies
Errors
Handling errorsHandling errors
Debugging
Request dataRequest data
Getting URLGetting URL

Node.js support

Visit this wiki page to see how you can use this SDK in Node.js environment.

Quick start

npm i kentico-cloud-delivery-typescript-sdk --save

TypeScript (ES6)

import { ContentItem, Fields } from 'kentico-cloud-delivery-typescript-sdk';

/**
Each content type needs to have model class
*/
export class Movie extends ContentItem {
  public title: Fields.TextField;
}

/**
* Type resolvers make sure instance of proper class is created for your content types
*/
let typeResolvers: TypeResolver[] = [
    new TypeResolver('movie', () => new Movie()),
  ];

/**
 * Create new instance of Delivery Client
 */
var deliveryClient = new DeliveryClient(
  new DeliveryClientConfig('projectId', typeResolvers)
  );

/**
* Get data from Cloud
*/
deliveryClient.items<Movie>()
  .type('movie')
  .get()
  .subscribe(response => {
    console.log(response);
    // you can access strongly types properties
    console.log(response.items[0].title.text);
  });

JavaScript (CommonJS)

var KenticoCloud = require('kentico-cloud-delivery-typescript-sdk');

/**
Each content type needs to have model class
*/
class Movie extends KenticoCloud.ContentItem {
    constructor() {
        super();
    }
}

/**
* Type resolvers make sure instance of proper class is created for your content types
*/
var typeResolvers = [
    new KenticoCloud.TypeResolver('movie', () => new Movie()),
];

/**
 * Delivery client configuration object
 */
var config = new KenticoCloud.DeliveryClientConfig(projectId, typeResolvers);

/**
 * Create new instance of Delivery Client
 */
var deliveryClient = new KenticoCloud.DeliveryClient(config);

/**
 * Fetch all items of 'movie' type and given parameters from Kentico Cloud
 */
deliveryClient.items()
    .type('movie')
    .get()
    .subscribe(response => console.log(response));

Scripts

  • Use npm test to run all tests.
  • Use npm run dev-test to run developer tests created in dev-test folder. Use this for your testing purposes.
  • Use npm run nodejs-test runs Node.js application and checks if response was successful
  • Use npm run build to generate definitions & dist from the contents of lib folder.
  • Use npm run coveralls to push coverage data directly to https://coveralls.io. Can be executed only after runningnpm test.

Feedback & Contribution

Feedback & Contributions are welcomed. Feel free to take/start an issue & submit PR.

kenticoclouddeliverytypescriptsdk's People

Contributors

enngage avatar petrsvihlik avatar christopherjennings avatar jancerman avatar

Watchers

James Cloos avatar Edouard Riviere avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.