diff --git a/package.json b/package.json index 434feee..4c3e1c5 100644 --- a/package.json +++ b/package.json @@ -27,12 +27,12 @@ "@graphql-codegen/introspection": "1.18.0", "@graphql-codegen/typescript": "1.17.10", "@graphql-codegen/typescript-resolvers": "1.17.10", + "@prisma/cli": "2.8.1", "@types/dotenv": "^8.2.0", "@types/jsonwebtoken": "^8.5.0", "dotenv": "^8.2.0", - "ts-node": "^9.0.0", - "typescript": "^4.0.3", "nodemon": "^2.0.4", - "@prisma/cli": "2.8.1" + "ts-node": "^9.0.0", + "typescript": "^4.0.3" } } diff --git a/src/controllers/auth.ts b/src/controllers/auth.ts index 33e3e0a..f3c01f9 100644 --- a/src/controllers/auth.ts +++ b/src/controllers/auth.ts @@ -10,6 +10,8 @@ import { CheckRightsAndResolve } from './types' import { getDBFormAuthor } from '../db' import { sendToken } from './mailer' +if (process.env.NODE_ENV === 'development') require('dotenv').config() + const checkRightsAndResolve: CheckRightsAndResolve = async (params) => { const { user, expected, controller } = params diff --git a/src/controllers/mailer.ts b/src/controllers/mailer.ts index 091ed12..9652367 100644 --- a/src/controllers/mailer.ts +++ b/src/controllers/mailer.ts @@ -1,5 +1,7 @@ import sgMail from '@sendgrid/mail' +if (process.env.NODE_ENV === 'development') require('dotenv').config() + sgMail.setApiKey('' + process.env.SENDGRID_API_KEY) const sendToken = (username: string, email: string, token: string) => { diff --git a/src/index.ts b/src/index.ts index 3b0da04..f6bacce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,8 @@ import { ApolloContextType, JwtPayloadType } from './types' import { ApolloServer, makeExecutableSchema } from 'apollo-server-express' import { PrismaClient } from '@prisma/client' +if (process.env.NODE_ENV === 'development') require('dotenv').config() + const app = express() app.use(