Skip to content

Commit

Permalink
fix: remove mailer from fastify request and graphql context (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshlohala committed Aug 21, 2023
1 parent 6550b3b commit ebac4a7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 53 deletions.
6 changes: 1 addition & 5 deletions packages/mailer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
"devDependencies": {
"@dzangolab/fastify-config": "0.40.1",
"@dzangolab/fastify-mercurius": "0.40.1",
"@types/mjml": "4.7.1",
"@types/node": "18.16.18",
"@types/nodemailer": "6.4.9",
Expand All @@ -52,7 +51,6 @@
"eslint-config-custom": "0.40.1",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"mercurius": ">=12.2.0",
"mjml": "4.14.1",
"prettier": "2.8.8",
"tsconfig": "0.40.1",
Expand All @@ -62,14 +60,12 @@
},
"peerDependencies": {
"@dzangolab/fastify-config": "0.40.1",
"@dzangolab/fastify-mercurius": "0.40.1",
"fastify": ">=4.9.2",
"fastify-plugin": ">=4.3.0",
"mercurius": ">=12.2.0",
"mjml": ">=4.13.0"
},
"engines": {
"node": ">=16",
"pnpm": ">=8"
}
}
}
10 changes: 0 additions & 10 deletions packages/mailer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ declare module "fastify" {
interface FastifyInstance {
mailer: FastifyMailer;
}

interface FastifyRequest {
mailer: FastifyMailer;
}
}

declare module "@dzangolab/fastify-config" {
Expand All @@ -18,12 +14,6 @@ declare module "@dzangolab/fastify-config" {
}
}

declare module "mercurius" {
interface MercuriusContext {
mailer?: FastifyMailer;
}
}

export { default } from "./plugin";

export type {
Expand Down
17 changes: 2 additions & 15 deletions packages/mailer/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@ import { htmlToText } from "nodemailer-html-to-text";
import { nodemailerMjmlPlugin } from "nodemailer-mjml";

import router from "./router";
import updateContext from "./updateContext";

import type { FastifyMailer } from "./types";
import type { MercuriusEnabledPlugin } from "@dzangolab/fastify-mercurius";
import type {
FastifyInstance,
FastifyPluginAsync,
FastifyRequest,
} from "fastify";
import type { FastifyInstance, FastifyPluginAsync } from "fastify";
import type { MailOptions } from "nodemailer/lib/sendmail-transport";

const plugin: FastifyPluginAsync = async (fastify: FastifyInstance) => {
Expand Down Expand Up @@ -74,9 +68,6 @@ const plugin: FastifyPluginAsync = async (fastify: FastifyInstance) => {
throw new Error("fastify-mailer has already been registered");
} else {
fastify.decorate("mailer", mailer);
fastify.addHook("onRequest", async (request: FastifyRequest) => {
request.mailer = mailer;
});
}

if (test && test?.enabled) {
Expand All @@ -86,8 +77,4 @@ const plugin: FastifyPluginAsync = async (fastify: FastifyInstance) => {
}
};

const fastifyPlugin = FastifyPlugin(plugin) as MercuriusEnabledPlugin;

fastifyPlugin.updateContext = updateContext;

export default fastifyPlugin;
export default FastifyPlugin(plugin);
13 changes: 0 additions & 13 deletions packages/mailer/src/updateContext.ts

This file was deleted.

16 changes: 6 additions & 10 deletions pnpm-lock.yaml

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

0 comments on commit ebac4a7

Please sign in to comment.