functionly-examples/todoDB-mongo at master · jaystack/functionly-examples · GitHub
Skip to content

Latest commit

 

History

History

Folders and files

README.md

todoDB

install and build

npm install

local mongo

create local mongodb with docker

docker run -d --name mongodb -p 27017:27017 mongodb

run in local

functionly start

then test it

curl -d '@content/todoPayload.json' -H "Content-Type: application/json" -X POST http://localhost:3000/createTodo
curl 'http://localhost:3000/getAllTodos'

aws requirements

import { NoCallbackWaitsForEmptyEventLoop } from 'functionly'

@use(NoCallbackWaitsForEmptyEventLoop)
export class TodoService extends FunctionalService { }

allows a Lambda function to return its result without close the database connection

deploy to aws (mongodb required)

create and setup your mongodb in aws and set the connection url in application

functionly deploy

it will create lambda functions and dynamoDB tables

run in aws

aws lambda invoke --function-name CreateTodo-dev --payload file://./content/todoPayload.json --region us-east-1 `tty`
aws lambda invoke --function-name GetAllTodos-dev --region us-east-1 `tty`