Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build": "tsc --build tsconfig.json",
"build:demo-app": "yarn workspace @pwrdrvr/lambda-dispatch-demo-app build",
"start:demo-app": "NUMBER_OF_WORKERS=${NUMBER_OF_WORKERS:-1} yarn workspace @pwrdrvr/lambda-dispatch-demo-app start:app",
"start:demo-app:logging": "NUMBER_OF_WORKERS=${NUMBER_OF_WORKERS:-1} yarn workspace @pwrdrvr/lambda-dispatch-demo-app start:app:logging",
"test": "yarn workspace @pwrdrvr/lambda-dispatch-cdk test && yarn workspace @pwrdrvr/lambda-dispatch-cdk-stack test"
},
"author": "",
Expand Down
14 changes: 9 additions & 5 deletions src/demo-app/app.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ const logFormat =

// Use the custom format
app.use(trackBytes);
app.use(morgan(logFormat));
if (process.env.LOGGING === 'true') {
app.use(morgan(logFormat));
}

const port = 3001;
const spdyPort = 3002;
Expand Down Expand Up @@ -371,7 +373,9 @@ app.post('/echo', async (req, res) => {
const timestamp = new Date().toISOString();
totalBytesReceived += chunk.length;
if (debugMode) {
console.log(`${logPrefix} - RECEIVED chunk ${chunk.length} bytes, total ${totalBytesReceived} bytes at ${timestamp}`);
console.log(
`${logPrefix} - RECEIVED chunk ${chunk.length} bytes, total ${totalBytesReceived} bytes at ${timestamp}`,
);
}

this.push(chunk);
Expand All @@ -383,7 +387,7 @@ app.post('/echo', async (req, res) => {
console.log(`${logPrefix} - FINISHED`);
}
callback();
}
},
});

// Pipe the req body to the response with back pressure
Expand Down Expand Up @@ -465,7 +469,7 @@ app.post('/double-echo', async (req, res) => {

app.post('/half-echo', async (req, res) => {
const contentType = req.get('Content-Type');

if (contentType) {
res.set('Content-Type', contentType);
}
Expand All @@ -492,7 +496,7 @@ app.post('/half-echo', async (req, res) => {
const halfLength = chunk.length >> 1;
this.push(chunk.slice(0, halfLength), 'binary');
callback();
}
},
});

// Pipe through halver transform then to response
Expand Down
1 change: 1 addition & 0 deletions src/demo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build:directlambda": "esbuild directlambda.mjs --bundle --platform=node --format=esm --external:./serverlessloader.cjs --outfile=dist/directlambda.mjs",
"build:serverlessloader": "esbuild serverlessloader.cjs --bundle --platform=node --format=cjs --outfile=dist/serverlessloader.cjs",
"start:app": "node dist/app.cjs",
"start:app:logging": "LOGGING=true node dist/app.cjs",
"start:directlambda": "node dist/directlambda.mjs"
},
"author": "PwrDrvr LLC",
Expand Down
Loading