Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
fix createWithServerProps()
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Aug 14, 2023
1 parent fa22ac9 commit 2c25d50
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log (@egomobile/next-utils)

## 0.9.3
## 0.9.4

- **BREAKING CHANGE**: improve use of execution contextes of `EnhanceApiContext`

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egomobile/next-utils",
"version": "0.9.3",
"version": "0.9.4",
"description": "Handy utils and extensions for Next.js",
"main": "lib/index.js",
"engines": {
Expand Down Expand Up @@ -75,4 +75,4 @@
"@egomobile/http-server": ">=0.63.1",
"next": ">=13.0.0"
}
}
}
17 changes: 6 additions & 11 deletions src/middlewares/withServerProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,6 @@ export function createWithServerProps<TContext = IWithServerPropsActionContext>(
null;

return (action?, options?) => {
if (!action) {
return wrapServerHandler(async () => {
return {
"props": {}
};
}, {
"use": options?.use
});
}

return wrapServerHandler(async (context) => {
try {
const actionContext: IWithServerPropsActionContext = {
Expand All @@ -167,7 +157,12 @@ export function createWithServerProps<TContext = IWithServerPropsActionContext>(
};
}

const resultProps = await action(enhanceExecCtx.context as unknown as TContext);
let resultProps = await action?.(enhanceExecCtx.context as unknown as TContext);
if (!resultProps) {
resultProps = {
"props": {}
};
}

return cloneObj(
deepmerge(
Expand Down

0 comments on commit 2c25d50

Please sign in to comment.