Skip to content

Commit

Permalink
Merge pull request #831 from nestjs/fix/context-instance-830
Browse files Browse the repository at this point in the history
fix(): assign req to object instead of object merge #830
  • Loading branch information
kamilmysliwiec authored Apr 30, 2020
2 parents 0ca55fa + 1ec9f38 commit c9a09a2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/utils/merge-defaults.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ export function mergeDefaults(
moduleOptions.context = async (...args: unknown[]) => {
const ctx = await (options.context as Function)(...args);
const { req } = args[0] as Record<string, unknown>;
if (typeof ctx === 'object') {
return {
req,
...ctx,
};
if (ctx && typeof ctx === 'object') {
ctx.req = req;
}
return ctx;
};
} else {
moduleOptions.context = ({ req }: Record<string, unknown>) => {
if (typeof options.context === 'object') {
return {
req,
...options.context,
};
if (options.context && typeof options.context === 'object') {
(options.context as Record<string, unknown>).req = req;
}
return options.context;
};
Expand Down

0 comments on commit c9a09a2

Please sign in to comment.