Skip to content

Award-winning backend prototype in Brainhack 2023 (CODE_EXP)

Notifications You must be signed in to change notification settings

officeverse/backend

Repository files navigation

Officeverse Backend

Table of Contents

Architecture

Our backend adopts a event-driven architecture, and uses the Serverless Framework to provision resources with EventBridge Infrastructure as Code.

Development

Setup

The following are pre-requisites for setting up the development environment:

git clone https://github.com/officeverse/backend.git
cd backend
npm install
rm -rf /amplify
amplify pull --appId <appId> --envName dev # Amplify CLI should already be comfigured

Development

Add the following snippet into serverless.yml:

custom:
  s3:
    host: localhost
    directory: /tmp

resources:
  Resources:
    NewResource:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: local-bucket

The above snippet should be removed prior to deployment

Run the local deployment environment with npm run local, which will start a local API Gateway server on http://localhost:3000, and a S3 bucket on http://localhost:4569.

Obtaining JWT for API Gateway

node -r dotenv/config scripts/cognitoLogin.mjs dotenv_config_path=.env.local

The resulting AccessToken should be passed into the Authorization header for authenticated access

To invoke functions locally

npx sls invoke local --function <functionName> --path <eventData>

Example

Simulating a PreSignUp event

npx sls invoke local --function preSignUpValidateCode --path events/preSignUpEvent.json

To put an object into the local bucket

bash scripts/localS3PutObject.sh <pathToFile>

The file data will be stored in /buckets/local-bucket

Deployment

To deploy the backend, you may run npm run deploy to provision resources on AWS servers.

About

Award-winning backend prototype in Brainhack 2023 (CODE_EXP)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published