Skip to content

How to: run dev locally

Ishmeal Baawuah edited this page Jun 15, 2021 · 1 revision

Local Dev:Run all the services locally with the command ./dev local

Prerequisites:

Node - we enforce using a specific version of node, specified in the file .nvmrc. This version matches the Lambda runtime. We recommend managing node versions using NVM.

Serverless - Get help installing it here: Serverless Getting Started page

Yarn - in order to install dependencies, you need to install yarn. If you are on a Mac, you should be able to install all the dependencies like so:

# install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash

# select the version specified in .nvmrc
nvm install
nvm use

# install yarn
brew install yarn

Steps:

  1. Open and run the following command in terminal from the project root directory:
    ./dev local
    

Notes:

Local Dev Run all the services locally with the command ./dev local See the prerequisite section if the command asks for any prerequisites you don't have installed. Local dev is configured in typescript project in ./src. The entrypoint is ./src/dev.ts, it manages running the moving pieces locally: the API, the database, the filestore, and the frontend. Local dev is built around the Serverless plugin serverless-offline. serverless-offline runs an API gateway locally configured by ./services/app-api/serverless.yml and hot reloads your lambdas on every save. The plugins serverless-dynamodb-local and serverless-s3-local stand up the local db and local s3 in a similar fashion. When run locally, auth bypasses Cognito. The frontend mimics login in local storage with a mock user and sends an id in the cognito-identity-id header on every request. serverless-offline expects that and sets it as the cognitoId in the requestContext for your lambdas, just like Cognito would in AWS.

Clone this wiki locally