Giter Site home page Giter Site logo

kontent-custom-element-tester's Introduction

Kontent.ai Custom Element Tester

Make local development and testing Kontent.ai Custom Elements a little easier by doing the following:

  1. Use a running service for hosting the Custom Element
  • Specify an address or port to use one already running (ex. for React apps, etc.)
  • OR Specify some options to automatically start an Express server to serve static files (ex. for a simple HTML file with a Custom Element)
  1. Use the address of the Custom Element to automatically create an ngrok tunnel
  2. Use said ngrok tunnel and Kontent.ai keys to create/update a test model with Custom Element property

If there is no model with the specified Kontent.ai codename, one will be created with a Custom Element and the address pointed to our ngrok tunnel. If there is a model already, anytime this utility is run the tunnel address will be updated accordingly with any updated ngrok tunnel address.

NOTE: Even though this utility does create the Content Model, you will need to create the Content Item.

Setup

First, make sure to have Node/NPM installed on your system.

Then, after cloning this repo, navigate to the repo root and run npm install to install the depedencies.

Configuration

The configuration file allows a few different options for configuring a server and ngrok tunnel. The file should be a Javascript file that exports the configuration object.

NOTE: there is a sample config file/object included in kcet.config.js that you can fill out and/or copy and use with the --config option (see below).

addr (OPTIONAL)

If addr property is present in the config object it will be used as an argument to ngrok

If it is a string then the value will be used without modification.

If it is a function, then the function will be called with the port configuration property and the result of the function will be used.

The default value is ''.

port (OPTIONAL)

The port number to use when creating an ngrok tunnel and/or starting an express server.

The default value is 8000.

express (OPTIONAL)

If the express property is present AND also contains a staticFilesPath sub-property, then an express server will be created, pointing to the specified static path to host. This can be used to setup and host a simple HTML file and custom element quickly.

The default value is null.

kontent (REQUIRED)

The kontent property is required and needs to also contain the projectId for your project, the apiKey for the Management API, and an elementCodename for the test model that will be created for testing your custom element.

Running

Run with node ./index.js

Using another config file/object

To use a separate config file, pass --config="<my config file path>" as an argument to the script.

ex. node ./index.js -- --config="~/myConfig.js"

kontent-custom-element-tester's People

Contributors

dependabot[bot] avatar mcbeev avatar mwebb-bzs avatar

Stargazers

 avatar

Watchers

 avatar  avatar

kontent-custom-element-tester's Issues

Update documentation

Description of the new feature / enhancement

We should update the documentation. As part of updating it, we should include the following:

  • Links to other NPM dependencies
  • Full configuration example
  • Better / updated formatting
  • Image / gif (this should not be hosted in the repo directly, but in GitHub, potentially attached to this issue)

Scenario when this would be used?

No response

Supporting information

No response

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.