Skip to content

Getting Started

Benedikt Schulze Baek edited this page Mar 9, 2017 · 29 revisions

This is a Step-By-Step Getting Started, that will help you setting up your first running projects using chayns® and the chayns® Backend API.
It is based on the GetLocationInfo-tapp located in this Repository and shows you the basics of setting up a project for working with the chayns® Backend API.

Requirements

Step 1 - Clone the project

  1. Clone or download the project from this Repository. It is located in the 'GetLocationInfo'-subdirectory
  2. Choose a programming language for the backend (C# or NodeJS).
  3. Follow the setup instructions inside the language folders for setting up the project properly.
    The backend project and the index.html file located in the 'GetLocationInfo' folder need to be available through the WWW.
  4. In the index.html file, replace the fetch url with the variable pointing to your selected backend.
  5. If you move the api to an other server, adjust the url in the index.html file, since it is pointing to localhost

Step 2 - Register a developer tapp

  1. Register a new developer tapp in the tapp administration in the TSPN
  2. Choose a name, then in the url field, point to the index.html mentioned in the last step
  3. Check the required permission PublicInfo (The required permissions are listed in the reference for each api endpoint)

Note the tapp secret and installation code.
The secret is required for authorization later on, the installation code is used to install this developer tapp on any chayns site.

Step 3 - Install the tapp

  1. On your chayns site, go to Configuration -> Tapps -> Add Tapp -> External Content
  2. Choose any name. Where it asks you to add an URL, just insert the installation code you copied from the tapp administration
  3. Now you can to agree to the requested permissions of the tapp you set in the tapp administration. Go ahead an the tapp is installed

Step 4 - Tapp Secret

If you open the console while on the tapp, there is an error log due to a 409-http error.
This is caused by the API because there is no tapp secret stored in the code and the request it performs is unauthorized.

  1. Open the project you selected and add the tapp secret of your developer tapp
  2. Follow the instructions
  • C#: Go to Controllers -> LocationController.cs and insert the tapp secret into the 'Secret'-variable
    • -> Rebuild the project
  • NodeJS: Go to Src -> index.js and insert the tapp secret into the 'Secret'-variable
    • -> Execute 'npm run server' via the NodeJS command line while in the NodeJS directory (if the server is running already, it refreshs itself)

Step 5 - Try it out

Now you can open the tapp on your chayns site and you can see the location info plotted in a content__card element.
The information shown are the name of your chayns site, it's siteId, locationId and the count of registered users.


Conclusion

The example used in this Getting Started showed you the basics of working with the chayns® Backend API.
It contains the code you need to fetch your own api which then will request the chayns Backend API and returns the response to the client.
You have learned how to register a developer tapp in the Tobit Software Partner Network and how to implement them on your own chayns site.

Last but not least you can take a look at our code snippets.
The Repository is a collection of frontend and backend snippets you can copy to your own project easily, since they work in the same way as this sample project.