Overview: Understanding the Boilerplate

Overview: Understanding the Boilerplate

Introduction

Making a brief overview of the Boilerplate, there are two directories (/node and /graphql) and the manifest.json file, which is an important file to your VTEX IO app because it will be the first communication point with the VTEX IO.

Manifest Overview

In the manifest.json file, you will find the app's name, vendor, version, and other information to pay attention to: builders, policies and dependencies. In this initial state, we have the following configurations:

  • builders: what builders your app will need. In this case, we currently only have the node builder, with its respective version;
  • policies: if the app being built needs to access some external services or get some specific data from other places, it needs to declare so, even for external APIs. At this point, we have no specific policies yet;
  • dependencies: other VTEX IO apps your app depends on. As addressed below, for this course, we need to also link the events-example app, as it is listed as a dependency for this course app.

/node Directory Overview

All directories used over the course are already in this initial project. Most of the directories are empty and will be filled throughout the course.

  • /node/clients: both files are almost blank and are now just placeholders for the next steps.

  • /node/handlers: contains a handler that will be used in the next steps.

  • /node/utils: you will find a file containing global constants declarations (/node/constants.ts).

  • /node/index.ts: contains the initial declarations for the app functionality like the cache declaration and the service declarations, which will be incremented during the course. Here it is also possible to export resolver functions implementations (for GraphQL).

  • /node/service.json: describes your REST API and some characteristics that will directly impact your app's infrastructure attributes.

    Your service.json file will be found inside your app's /node folder, and will look similar to this:

    {
    "memory": 256,
    "timeout": 2,
    "minReplicas": 2,
    "maxReplicas": 4,
    "routes": {
      "status": {
        "path": "/_v/status/:code",
        "public": true
      }
    }
    
    FieldTypeDescription
    memoryMegaBytes.How much memory your app will have allocated. This value will be overwritten if IO detects that your app is abusing memory usage
    timeoutSecondsVTEX.IO infra will abort the connection if the request time is longer than timeout
    minReplicasIntegerWhen your app is running, how many minimum replicas will be available
    maxReplicasIntegerThe largest amount of replicas that will be available
    routes-Describes your app's REST routes, inside you will describe the name, (ex: ssr), the path, and if it's public or private

/graphql Directory Overview

On this directory, you will find only the empty directories and the /graphql/schema.graphql blank file. This will all be filled throughout the course, as well.

Dependencies

For this course, this app has a dependency on the events-example app. The events-example app, when linked to your account and workspace, is responsible for providing events examples. Over the course, as we approach the events topic, there will be a more complete overview of the events-example app.

Getting started

  1. For now, clone (git clone) the events-example app from this repository and run vtex link in it's directory.

Without the events-example app, this course app will not be successfully linked, as the events-example app is listed as a dependency.

After running vtex link on the events-example app, the terminal should show a healthcheck route that will be used later. It looks like this:

image


Help us make this content better!

VTEX IO courses are open source. If you see something wrong, you can open a pull request!

Make a contribution

or open an issue