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
5 changes: 5 additions & 0 deletions .changeset/hot-lions-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@driimus/aws-event-factory": patch
---

feat(deps): require faker v9
5 changes: 5 additions & 0 deletions .changeset/strong-pans-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@driimus/lambda-batch-processor": patch
---

docs: reference alternative implementations
23 changes: 8 additions & 15 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,24 @@ export default tsEslint.config(
rules: {
'prefer-const': ['error', { destructuring: 'all' }],
'unicorn/filename-case': ['warn', { case: 'camelCase' }],
'unicorn/prevent-abbreviations': 'warn',
'unicorn/no-null': 'off',
'unicorn/no-useless-switch-case': 'error',
'unicorn/prevent-abbreviations': 'warn',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksConditionals: true,
},
],
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
},
},
{
Expand All @@ -84,9 +78,7 @@ export default tsEslint.config(
'@typescript-eslint/no-unsafe-assignment': 'off',
},
languageOptions: {
globals: {
...vitest.environments.env.globals,
},
globals: vitest.environments.env.globals,
},
},
{
Expand All @@ -96,6 +88,7 @@ export default tsEslint.config(
turbo,
},
rules: {
...tsEslint.configs.disableTypeChecked,
'turbo/no-undeclared-env-vars': 'error',
},
},
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"@tsconfig/strictest": "^2.0.5",
"@types/aws-lambda": "^8.10.131",
"@types/node": "^20.16.5",
"@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vitest/coverage-v8": "^2.0.0",
"@vitest/eslint-plugin": "^1.1.4",
"eslint": "^9.10.0",
"eslint": "^9.11.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import-x": "^4.2.1",
"eslint-plugin-import-x": "^4.3.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-turbo": "^2.1.2",
Expand All @@ -39,7 +39,7 @@
"prettier": "^3.2.4",
"turbo": "^2.0.1",
"typescript": "^5.3.3",
"typescript-eslint": "^8.5.0",
"typescript-eslint": "^8.7.0",
"vitest": "^2.0.0"
},
"packageManager": "pnpm@9.1.4",
Expand Down
33 changes: 4 additions & 29 deletions packages/lambda-batch-processor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ For types to work as expected, `@types/aws-lambda` must be installed:

```sh
pnpm add --save-dev @types/aws-lambda

```

## Usage
Expand Down Expand Up @@ -70,37 +69,13 @@ To send SQS messages to a dead-letter queue, you can use [`@driimus/sqs-permanen

### Logging

You can enable logging by providing a logger compatible with the `Logger` interface,
Logging can be enabled by providing a logger compatible with the `Logger` interface,
which is modelled after [pino](https://github.com/pinojs/pino)'s function signatures.

> [!NOTE]
> The provided logger should support serialising [AggregateError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) objects.

If using pino, it might be worth adding [pino-lambda](https://github.com/formidablelabs/pino-lambda),
to preserve Lambda's standard log message format.

```ts
import { SQSBatchProcessor } from '@driimus/lambda-batch-processor';
import pino from 'pino';
import { lambdaRequestTracker, pinoLambdaDestination } from 'pino-lambda';

const destination = pinoLambdaDestination();
const withRequest = lambdaRequestTracker();
## Alternatives

const logger = pino({}, destination);

const processor = new SQSBatchProcessor(
async (record) => {
/** do stuff */
},
{
logger,
},
);

export const handler = async (event, context) => {
withRequest(event, context);

return await processor.process(event, context);
};
```
Don't need special handling for [non-retryable errors](#non-retryable-errors)?
Make sure to check out the implementation in [AWS Lambda Powertools for Typescript](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/batch#readme), which has added ESM support in v2.
Loading