Skip to content

Commit

Permalink
refactor(app): migrate to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
MathRobin committed Nov 17, 2023
1 parent 9b790bf commit e59f341
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: [ 18, 19, 20, 21 ]
version: [18, 19, 20, 21]
steps:
- uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
compressionLevel: mixed

defaultSemverRangePrefix: ""
defaultSemverRangePrefix: ''

enableGlobalCache: false

Expand Down
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,43 @@ ESM only since v3. Typings included.
Deadly simple

```javascript
import { ok, internalServerError } from "lambda-returns";
import { ok, internalServerError } from 'lambda-returns';

export default async () => {
try {

return ok({
status: "success"
status: 'success',
});
} catch (err) {

return internalServerError({
status: "error",
error: err
status: 'error',
error: err,
});
}
}
};
```

instead of that non-funny code:

```javascript
export default async () => {
try {

return {
statusCode: 200,
body: JSON.stringify({
status: "success"
status: 'success',
}),
};
} catch (err) {

return {
statusCode: 500,
body: JSON.stringify({
status: "error",
error: err
status: 'error',
error: err,
}),
};
}
}
};
```

### Test helpers methods
Expand All @@ -63,7 +59,7 @@ Not enough for you? For me too. This package provides a simple way to test your
handler method.

```javascript
import { isOk, isBadRequest } from "lambda-returns";
import { isOk, isBadRequest } from 'lambda-returns';

expect(isOk(result)).toBeTruthy();
expect(isBadRequest(result)).toBeTruthy();
Expand All @@ -90,8 +86,7 @@ You ? Me no. And don't want/need to.
Moreover, into vanilla AWS lambda way, you need to return a string as body. But just stringify your result is dangerous,
if you have a dynamic result, maybe is null, maybe is undefined, maybe you already have a string.


F*ck! I don't want to care of it in my business logic! `lambda-returns` manages it for you.
F\*ck! I don't want to care of it in my business logic! `lambda-returns` manages it for you.

## Cons

Expand All @@ -104,4 +99,4 @@ export const continue = {}; // or whatever;

This is just forbidden. If you knwon any way to go over this problem, tell me.

Despite to this problem, test helper method `isContinue` is available.
Despite to this problem, test helper method `isContinue` is available.

0 comments on commit e59f341

Please sign in to comment.