Skip to content

Latest commit

 

History

History
97 lines (60 loc) · 3.84 KB

File metadata and controls

97 lines (60 loc) · 3.84 KB

Setup a Redis Data Store

Serve the Frontend from a Function

Skip to "Set Up a Redis Datastore"

Download assets and get started

Setup Your Binaris Environment

For the next section you will need a Binaris account, if you already have one skip the following four steps.

  1. Visit signup
  2. Follow the instructions and create your new Binaris account
  3. Install the CLI via npm
    npm install binaris -g
  4. Use bn login to authenticate with your newly created Binaris account
  5. (Optional) visit our getting started page to learn the basics

Setup the Frontend

$ cd frontend

Add a "homepage" so that React routing uses your account specific function URL. Make sure to replace <ACCOUNT_ID> with your specific Binaris account ID. Assuming you successfully ran bn login, your account ID can be found in ~/.binaris.yml.

Note: Your account ID will always be a unique number, 10 digits in length.

> frontend/package.json
---
 "private": true,
-"homepage": "https://run.binaris.com/v2/run/<ACCOUNT_ID>/public_serve_todo",
+"homepage": "https://run.binaris.com/v2/run/23232*****/public_serve_todo",
 "dependencies": {

And then run the following commands

$ npm install
$ cd serve_todo
$ npm install

To verify that you've successfully caught up...

$ cd ../
$ npm run build && npm run deploy

Table of Contents

  1. Create Your Redis Account
  2. Create Your Redis Instance

First thing we need to do, before writing the backend functions, is get a datastore for them to utilize. For this tutorial, we will be using Redis, since it's fast, easy to set up, and doesn't require a payment method for the free tier.

Create Redis Account

Let's start by creating a Redis account. You can sign up for the service for free here. This will require you to provide a first and last name, email, a name for your database (anything goes), your country of residence, and a password.

Redis Step 1

After submitting, you will be asked to verify your email address. You will then be directed to choose a plan. This will involve you selecting a Cloud, picking a subscription name (whatever you like), and selecting your usage tier (to use it for free, select Standard/30MB).

Redis Step 1

Note: We recommend using AWS/us-east-1 as the Redis Cloud provider.

After completing this step, you will be directed to setup an instance.

Create a Redis Instance

Now that we have a plan, you'll be directed to create an instance. Here, you need to enter a name for your database, preferably something relevant. Then you will want to hit the BLUE button at the end of the password line. Copy this password somewhere safe, we will need it later.

Redis Step 1

Click activate and your instance will be created, and you will be redirected to an information page about your instance. If the Endpoint field is not already populated, wait a few seconds and refresh the page. Once you see this field non-empty, copy this endpoint, which we will call your redis host, up until, but not including the :<PORT_NUMBER> at the end, and then copy the port number at the end of it.

Redis Step 1

Build a CRUD Backend with Functions >