This repository was archived by the owner on Dec 15, 2025. It is now read-only.
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 11{
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
52 "version" : " 0.2.0" ,
63 "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+ }
1315 ]
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
175175- [ AWS Lambda] ( https://aws.amazon.com/lambda/features/ )
176176- [ AWS S3] ( https://aws.amazon.com/s3/ )
177177
178- ## Develop locally
178+ ## Develop and debug locally
179179
180180db.json file will be loaded directly from your local filesystem. No AWS access is needed.
181181
182- #### 1. Start solution
182+ #### Start solution
183183
184184``` bash
185185npm run start
186186```
187187
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+
188195#### 2. Test your API
189196
190197To test you can use e.g. [ Postman] ( https://www.getpostman.com/ )
Original file line number Diff line number Diff line change 55 "main" : " src/server.js" ,
66 "scripts" : {
77 "test" : " npm run build & NODE_ENV=local jest" ,
8+ "debug" : " NODE_ENV=debug webpack --watch" ,
89 "start" : " NODE_ENV=local webpack --watch" ,
910 "dev" : " NODE_ENV=development webpack --watch" ,
1011 "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) => {
1919} ;
2020
2121if ( require . main === module ) {
22- if ( process . env . NODE_ENV === 'local' ) {
22+ if ( process . env . NODE_ENV === 'local' || process . env . NODE_ENV === 'debug' ) {
2323 start ( app . server , 3000 ) ;
2424 } else if ( process . env . NODE_ENV === 'development' ) {
2525 ( async ( ) => {
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ const request = async () => {
4848
4949function init ( ) {
5050 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' ) {
5252 startLocal ( 3000 ) ;
5353 } else if ( process . env . NODE_ENV === 'development' || process . env . NODE_ENV === 'offline' ) {
5454 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');
44const NodeEnvPlugin = require ( 'node-env-webpack-plugin' ) ;
55const NodemonPlugin = require ( 'nodemon-webpack-plugin' ) ;
66const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
7-
7+ const { join } = require ( 'path' ) ;
88
99module . exports = {
1010 mode : 'development' ,
@@ -15,17 +15,22 @@ module.exports = {
1515 new NodeEnvPlugin ( {
1616 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) ,
1717 } ) ,
18- new NodemonPlugin ( {
19- } ) ,
18+ process . env . NODE_ENV === 'debug' ? new NodemonPlugin ( { nodeArgs : [ '--inspect-brk' ] } ) : new NodemonPlugin ( ) ,
2019 ] ,
2120 entry : { 'src/handler' : './src/handler.js' } ,
2221 optimization : {
2322 minimizer : [ new TerserPlugin ( ) ] ,
2423 } ,
2524 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]' ,
2832 } ,
33+
2934 target : 'node' ,
3035 externals : [ nodeExternals ( ) ] ,
3136 module : {
You can’t perform that action at this time.
0 commit comments