Skip to content

Commit 3ed7c67

Browse files
committed
update todoDB-mongo example
1 parent 4c60cd7 commit 3ed7c67

File tree

8 files changed

+1472
-92
lines changed

8 files changed

+1472
-92
lines changed

todoDB-mongo/README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## install and build
44
```sh
55
npm install
6-
npm run build
76
```
87

98

@@ -16,21 +15,18 @@ docker run -d --name mongodb -p 27017:27017 mongodb
1615

1716
# run in local
1817
```sh
19-
npm start
20-
```
21-
or
22-
```sh
23-
npm run build
24-
functionly local 3000 ./lib/todoDB.js
18+
functionly start
2519
```
2620
then test it
2721
```sh
28-
curl 'http://localhost:3000/createTodo?name=corpjs&description=corpjs-meetup&status=new'
22+
curl -d '@content/todoPayload.json' -H "Content-Type: application/json" -X POST http://localhost:3000/createTodo
2923
curl 'http://localhost:3000/getAllTodos'
3024
```
3125

3226
# aws requirements
3327
```js
28+
import { NoCallbackWaitsForEmptyEventLoop } from 'functionly'
29+
3430
@use(NoCallbackWaitsForEmptyEventLoop)
3531
export class TodoService extends FunctionalService { }
3632
```
@@ -39,16 +35,12 @@ allows a Lambda function to return its result without close the database connect
3935
# deploy to aws (mongodb required)
4036
create and setup your mongodb in aws and set the connection url in application
4137
```sh
42-
functionly deploy aws ./lib/todoDB.js --aws-region us-east-1
43-
```
44-
or if you configured a functionly.json in your project root
45-
```sh
4638
functionly deploy
4739
```
4840
it will create lambda functions and dynamoDB tables
4941

5042
# run in aws
5143
```sh
52-
aws lambda invoke --function-name CreateTodo-example --payload file://./content/todoPayload.json --region us-east-1 ./dist/corpjs && cat ./dist/corpjs
53-
aws lambda invoke --function-name GetAllTodos-example --region us-east-1 ./dist/corpjs && cat ./dist/corpjs
44+
aws lambda invoke --function-name CreateTodo-dev --payload file://./content/todoPayload.json --region us-east-1 `tty`
45+
aws lambda invoke --function-name GetAllTodos-dev --region us-east-1 `tty`
5446
```

todoDB-mongo/content/readme.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
aws lambda invoke --function-name CreateTodo-example --payload file://./content/todoPayload.json --region us-east-1 /tmp/corpjs
3-
aws lambda invoke --function-name GetAllTodos-example --region us-east-1 /tmp/corpjs
2+
aws lambda invoke --function-name CreateTodo-dev --payload file://./content/todoPayload.json --region us-east-1 `tty`
3+
aws lambda invoke --function-name GetAllTodos-dev --region us-east-1 `tty`
44

5-
curl 'http://localhost:3000/createTodo?name=corpjs&description=corpjs-meetup&status=new'
5+
curl -d '@content/todoPayload.json' -H "Content-Type: application/json" -X POST http://localhost:3000/createTodo
66
curl 'http://localhost:3000/getAllTodos'

todoDB-mongo/content/todoPayload.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "corpjs",
3-
"description": "corpjs meetup",
2+
"name": "functionly",
3+
"description": "todo description",
44
"status": "new"
55
}

todoDB-mongo/functionly.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"debug": false,
3-
"awsRegion": "ue-east-1",
4-
"main": "./lib/todoDB.js",
3+
"awsRegion": "us-east-1",
4+
"main": "./src/todoDB.ts",
55
"deployTarget": "aws",
66
"localPort": 3000,
7-
"stage": "example"
7+
"stage": "dev",
8+
"watch": true,
9+
"compile": "ts-loader"
810
}

0 commit comments

Comments
 (0)