File tree Expand file tree Collapse file tree 8 files changed +1472
-92
lines changed Expand file tree Collapse file tree 8 files changed +1472
-92
lines changed Original file line number Diff line number Diff line change 3
3
## install and build
4
4
``` sh
5
5
npm install
6
- npm run build
7
6
```
8
7
9
8
@@ -16,21 +15,18 @@ docker run -d --name mongodb -p 27017:27017 mongodb
16
15
17
16
# run in local
18
17
``` sh
19
- npm start
20
- ```
21
- or
22
- ``` sh
23
- npm run build
24
- functionly local 3000 ./lib/todoDB.js
18
+ functionly start
25
19
```
26
20
then test it
27
21
``` 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
29
23
curl ' http://localhost:3000/getAllTodos'
30
24
```
31
25
32
26
# aws requirements
33
27
``` js
28
+ import { NoCallbackWaitsForEmptyEventLoop } from ' functionly'
29
+
34
30
@use (NoCallbackWaitsForEmptyEventLoop)
35
31
export class TodoService extends FunctionalService { }
36
32
```
@@ -39,16 +35,12 @@ allows a Lambda function to return its result without close the database connect
39
35
# deploy to aws (mongodb required)
40
36
create and setup your mongodb in aws and set the connection url in application
41
37
``` 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
46
38
functionly deploy
47
39
```
48
40
it will create lambda functions and dynamoDB tables
49
41
50
42
# run in aws
51
43
``` 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 `
54
46
```
Original file line number Diff line number Diff line change 1
1
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`
4
4
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
6
6
curl 'http://localhost:3000/getAllTodos'
Original file line number Diff line number Diff line change 1
1
{
2
- "name" : " corpjs " ,
3
- "description" : " corpjs meetup " ,
2
+ "name" : " functionly " ,
3
+ "description" : " todo description " ,
4
4
"status" : " new"
5
5
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"debug" : false ,
3
- "awsRegion" : " ue -east-1" ,
4
- "main" : " ./lib /todoDB.js " ,
3
+ "awsRegion" : " us -east-1" ,
4
+ "main" : " ./src /todoDB.ts " ,
5
5
"deployTarget" : " aws" ,
6
6
"localPort" : 3000 ,
7
- "stage" : " example"
7
+ "stage" : " dev" ,
8
+ "watch" : true ,
9
+ "compile" : " ts-loader"
8
10
}
You can’t perform that action at this time.
0 commit comments