npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

banjo-kentico-cloud-delivery

v1.0.4

Published

Fork of Official Kentico Cloud Delivery SDK

Downloads

737

Readme

Angular Universal Friendly Kentico Cloud Delivery SDK

Fork of the Official Kentico Cloud SDK.

This has a very specific purpose which is to provide a means bypass the in-build http client (axios) in-order to use Angular's in built http client. This is an important when using Angular Universal. If you don't need to bypass the default client, use the Official SDK.

Angular Universal requires all http requests to be performed using it's inbuilt HTTP client. This official SDK will work, however the server side will render before Observable or Promise has resolved. After extensive attempts work arounds this was the only solution which I found.

Related GitHub issue - https://github.com/angular/universal/issues/842

Things to be aware of;

  • Built in SDK re-try logic is bypassed, it's up to you to implement this yourself as part of your http client implementation.
  • Axios dependencies still exist to keep default logic working, the goal of this fork was to make non breaking changes to the origin project. This will add unessesary payload to the browser build.
  • This is not currently covered by testing, this is a proof of concept.

Install

npm install banjo-kentico-cloud-delivery

Usage example

// Angular imports
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { DeliveryClient, ItemResponses } from 'banjo-kentico-cloud-delivery';

@Injectable({
  providedIn: 'root'
})
export class NewsService {

    private client: DeliveryClient;

    constructor(private http: HttpClient) {
        this.client = new DeliveryClient({
            projectId: 'xxxxxxx'
        });
    }

    /**
    * Single Item Query
    */
    getNewsArticle(urlSlug: string): Observable<ItemResponses.DeliveryItemResponse<NewsArticle>> {
        // create query as per official SDK
        const query = this.client.items<NewsArticle>()
        .type('news_article')
        .equalsFilter('elements.url_slug', urlSlug)
        .limitParameter(1)
        .depthParameter(3);

        // get kentico request URL from query builder
        const url = query.getUrl();

        // perform Angular HTTP GET request
        return this.http.get(url).pipe(
            map((response: any, index: number) => {
                // Pass raw response body into our custom method
                return query.injectSingleItem(response);
            })
        );
    }

    /**
    * Multiple Item Query
    */
    getNewsArticles(): Observable<ItemResponses.DeliveryItemListingResponse<NewsArticle>> {
        // create query as per official SDK
        const query = this.client.items<NewsArticle>()
        .type('news_article')
        .depthParameter(3);

        // get kentico request URL from query builder
        const url = query.getUrl();

        return this.http.get(url).pipe(
            map((response: any, index: number) => {
            		// Pass raw response body into our custom method
                return query.injectMultipleItems(response);
            })
        );
    }
}