@contentchef/contentchef-management-js-client
TypeScript icon, indicating that this package has built-in type declarations

9.5.13 • Public • Published

ContentChef Management JS Client

Installing

Using npm:

    $ npm install @contentchef/contentchef-management-js-client

Using yarn:

    $ yarn add @contentchef/contentchef-management-js-client

Examples

  • Configuration example This code will show how to correctly configure your ContentChef Management JS Client
    class ContentChefApi {
        api: ContentChefClient;

        // The token is the authorizer that is needed to make actions in your space, for security problems the operation of setting the token
        // should me make in a server side application
        apiTokenResolver: AuthenticationTokenResolver = {
                getToken: async () => {
                   return await 'do stuffs to retrieve your api token';
                }
            };
            
        spaceIdResolver: SpaceIdResolver = {
            getSpaceId: async () => {
                return await 'do Stuff to retrieve your space id';
            }
        };

        initializeClient = () => {
            this.api = createChefSpaceClient(apiTokenResolver, spaceIdResolver, { apiRoot: 'https://api.contentchef.io' });
        }
    }

    // We do this to create a singleton of the client
    export const contentChefApi = new ContentChefApi().initializeClient();
  • Usage example This code will show how to correctly use your ContentChef Management JS Client after the initial configuration
    class ContentChefContentStore {
        api: ContentChefClient;

        constructor (chefApi: ContentChefClient) {
            this.api = chefApi
        }
    
        async getContent (reqParams: GetContentRequest) {
            try {
                const response = await this.api.contents.get(reqParam);
                console.log('This is the requested content');
                console.log(response);
            } catch (e) {
               console.log(`An error occurred retrieving the content with id ${reqParams.id}`);
               console.log(e); 
            } 
        }

    }

Docs

To generate a new Documentation simply run the command

Using yarn:

    $ yarn generate-docs

A new documentation will be created inside the folder docs in the root of the project, then simply serve the index.html file inside the docs folder in your browser

Readme

Keywords

none

Package Sidebar

Install

npm i @contentchef/contentchef-management-js-client

Weekly Downloads

1

Version

9.5.13

License

UNLICENSED

Unpacked Size

243 kB

Total Files

105

Last publish

Collaborators

  • bcoders
  • apalumbo