File tree Expand file tree Collapse file tree 6 files changed +34
-19
lines changed Expand file tree Collapse file tree 6 files changed +34
-19
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
3
- // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
4
- // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
5
2
"version" : " 0.2.0" ,
6
3
"configurations" : [
7
- {
8
- "type" : " node" ,
9
- "request" : " launch" ,
10
- "name" : " Launch Program" ,
11
- "program" : " ${workspaceFolder}\\ src\\ handler.js"
12
- }
4
+ {
5
+ "name" : " Launch Program" ,
6
+ "type" : " node" ,
7
+ "request" : " launch" ,
8
+ "cwd" : " ${workspaceRoot}" ,
9
+ "program" : " ${workspaceRoot}/src/handler.js" ,
10
+ "outFiles" : [
11
+ " ${workspaceRoot}/dist/handler.js"
12
+ ],
13
+ "sourceMaps" : true
14
+ }
13
15
]
14
- }
16
+ }
Original file line number Diff line number Diff line change @@ -175,16 +175,23 @@ curl -H "x-api-key: {API - KEY}" -H "Content-Type: application/json" https://xxx
175
175
- [ AWS Lambda] ( https://aws.amazon.com/lambda/features/ )
176
176
- [ AWS S3] ( https://aws.amazon.com/s3/ )
177
177
178
- ## Develop locally
178
+ ## Develop and debug locally
179
179
180
180
db.json file will be loaded directly from your local filesystem. No AWS access is needed.
181
181
182
- #### 1. Start solution
182
+ #### Start solution
183
183
184
184
``` bash
185
185
npm run start
186
186
```
187
187
188
+ #### Debug solution
189
+ If you want to debug locally in VS Code everything is already setup (using webpack with sourcemap support)
190
+
191
+ ``` bash
192
+ npm run debug
193
+ ```
194
+
188
195
#### 2. Test your API
189
196
190
197
To test you can use e.g. [ Postman] ( https://www.getpostman.com/ )
Original file line number Diff line number Diff line change 5
5
"main" : " src/server.js" ,
6
6
"scripts" : {
7
7
"test" : " npm run build & NODE_ENV=local jest" ,
8
+ "debug" : " NODE_ENV=debug webpack --watch" ,
8
9
"start" : " NODE_ENV=local webpack --watch" ,
9
10
"dev" : " NODE_ENV=development webpack --watch" ,
10
11
"diagnostic" : " NODE_ENV=offline sls offline" ,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ module.exports.handler = async (event, context) => {
19
19
} ;
20
20
21
21
if ( require . main === module ) {
22
- if ( process . env . NODE_ENV === 'local' ) {
22
+ if ( process . env . NODE_ENV === 'local' || process . env . NODE_ENV === 'debug' ) {
23
23
start ( app . server , 3000 ) ;
24
24
} else if ( process . env . NODE_ENV === 'development' ) {
25
25
( async ( ) => {
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ const request = async () => {
48
48
49
49
function init ( ) {
50
50
logger . info ( `NODE_ENV: ${ process . env . NODE_ENV } ` ) ;
51
- if ( process . env . NODE_ENV === 'local' ) {
51
+ if ( process . env . NODE_ENV === 'local' || process . env . NODE_ENV === 'debug' ) {
52
52
startLocal ( 3000 ) ;
53
53
} else if ( process . env . NODE_ENV === 'development' || process . env . NODE_ENV === 'offline' ) {
54
54
logger . info ( 'start development mode' ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const CopyPlugin = require('copy-webpack-plugin');
4
4
const NodeEnvPlugin = require ( 'node-env-webpack-plugin' ) ;
5
5
const NodemonPlugin = require ( 'nodemon-webpack-plugin' ) ;
6
6
const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
7
-
7
+ const { join } = require ( 'path' ) ;
8
8
9
9
module . exports = {
10
10
mode : 'development' ,
@@ -15,17 +15,22 @@ module.exports = {
15
15
new NodeEnvPlugin ( {
16
16
'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) ,
17
17
} ) ,
18
- new NodemonPlugin ( {
19
- } ) ,
18
+ process . env . NODE_ENV === 'debug' ? new NodemonPlugin ( { nodeArgs : [ '--inspect-brk' ] } ) : new NodemonPlugin ( ) ,
20
19
] ,
21
20
entry : { 'src/handler' : './src/handler.js' } ,
22
21
optimization : {
23
22
minimizer : [ new TerserPlugin ( ) ] ,
24
23
} ,
25
24
devtool : 'source-map' ,
26
- devServer : {
27
- contentBase : './dist' ,
25
+ output : {
26
+ path : join ( __dirname , 'dist' ) ,
27
+ filename : 'handler.js' ,
28
+
29
+ // Bundle absolute resource paths in the source-map,
30
+ // so VSCode can match the source file.
31
+ devtoolModuleFilenameTemplate : '[absolute-resource-path]' ,
28
32
} ,
33
+
29
34
target : 'node' ,
30
35
externals : [ nodeExternals ( ) ] ,
31
36
module : {
You can’t perform that action at this time.
0 commit comments