You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-4Lines changed: 68 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -22,11 +22,11 @@ plugins:
22
22
- serverless-plugin-typescript
23
23
```
24
24
25
-
## Example
25
+
## Configure
26
26
27
27
See [example folder](example) for a minimal example.
28
28
29
-
## `tsconfig.json`
29
+
###`tsconfig.json`
30
30
31
31
The default `tsconfig.json` file used by the plugin looks like this:
32
32
@@ -43,14 +43,78 @@ The default `tsconfig.json` file used by the plugin looks like this:
43
43
}
44
44
```
45
45
46
-
> Note 1: The `outDir` option cannot be overwritten.
46
+
> Note 1: The `outDir` and `rootDir` options cannot be overwritten.
47
47
48
48
> Note 2: Don't confuse the [`tsconfig.json`](tsconfig.json) in this repository with the one mentioned above.
49
49
50
-
## Including extra files
50
+
### Including extra files
51
51
52
52
All files from `package/include` will be included in the final build file. See [Exclude/Include](https://serverless.com/framework/docs/providers/aws/guide/packaging#exclude--include)
53
53
54
+
55
+
## Usage
56
+
57
+
### Automatic compilation
58
+
59
+
The normal Serverless deploy procedure will automatically compile with Typescript:
60
+
61
+
- Create the Serverless project with `serverless create -t aws-nodejs`
62
+
- Install Serverless Typescript as above
63
+
- Deploy with `serverless deploy`
64
+
65
+
### Usage with serverless-offline
66
+
67
+
The plugin integrates very well with [serverless-offline][https://github.com/dherault/serverless-offline] to
68
+
simulate AWS Lambda and AWS API Gateway locally.
69
+
70
+
Add the plugins to your `serverless.yml` file and make sure that `serverless-plugin-typescript`
71
+
precedes `serverless-offline` as the order is important:
72
+
```yaml
73
+
plugins:
74
+
...
75
+
- serverless-plugin-typescript
76
+
...
77
+
- serverless-offline
78
+
...
79
+
```
80
+
81
+
Run `serverless offline` or `serverless offline start` to start the Lambda/API simulation.
82
+
83
+
In comparison to `serverless offline`, the `start` command will fire an `init` and a `end` lifecycle hook which is needed for `serverless-offline` and e.g. `serverless-dynamodb-local` to switch off resources (see below)
84
+
85
+
#### serverless-dynamodb-local
86
+
87
+
Configure your service the same as mentioned above, but additionally add the `serverless-dynamodb-local`
88
+
plugin as follows:
89
+
```yaml
90
+
plugins:
91
+
- serverless-plugin-typescript
92
+
- serverless-dynamodb-local
93
+
- serverless-offline
94
+
```
95
+
96
+
Run `serverless offline start`.
97
+
98
+
#### Other useful options
99
+
100
+
You can reduce the clutter generated by `serverless-offline` with `--dontPrintOutput` and
101
+
disable timeouts with `--noTimeout`.
102
+
103
+
### Run a function locally
104
+
105
+
To run your compiled functions locally you can:
106
+
107
+
```bash
108
+
$ serverless invoke local --function <function-name>
109
+
```
110
+
111
+
Options are:
112
+
113
+
- `--function`or `-f` (required) is the name of the function to run
114
+
- `--watch`- recompile and run a function locally on source changes
115
+
- `--path`or `-p` (optional) path to JSON or YAML file holding input data
116
+
- `--data`or `-d` (optional) input data
117
+
54
118
## Help & Community [](https://slack.graph.cool)
55
119
56
120
Join our [Slack community](http://slack.graph.cool/) if you run into issues or have questions. We love talking to you!
0 commit comments