Fixed environment variables in development

This commit is contained in:
Dmitriy Shishkov 2020-11-11 23:03:00 +05:00
parent c09a66c6dd
commit aa73cc9a83
No known key found for this signature in database
GPG Key ID: D76D70029F55183E
4 changed files with 9 additions and 3 deletions

View File

@ -27,12 +27,12 @@
"@graphql-codegen/introspection": "1.18.0", "@graphql-codegen/introspection": "1.18.0",
"@graphql-codegen/typescript": "1.17.10", "@graphql-codegen/typescript": "1.17.10",
"@graphql-codegen/typescript-resolvers": "1.17.10", "@graphql-codegen/typescript-resolvers": "1.17.10",
"@prisma/cli": "2.8.1",
"@types/dotenv": "^8.2.0", "@types/dotenv": "^8.2.0",
"@types/jsonwebtoken": "^8.5.0", "@types/jsonwebtoken": "^8.5.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.3",
"nodemon": "^2.0.4", "nodemon": "^2.0.4",
"@prisma/cli": "2.8.1" "ts-node": "^9.0.0",
"typescript": "^4.0.3"
} }
} }

View File

@ -10,6 +10,8 @@ import { CheckRightsAndResolve } from './types'
import { getDBFormAuthor } from '../db' import { getDBFormAuthor } from '../db'
import { sendToken } from './mailer' import { sendToken } from './mailer'
if (process.env.NODE_ENV === 'development') require('dotenv').config()
const checkRightsAndResolve: CheckRightsAndResolve = async (params) => { const checkRightsAndResolve: CheckRightsAndResolve = async (params) => {
const { user, expected, controller } = params const { user, expected, controller } = params

View File

@ -1,5 +1,7 @@
import sgMail from '@sendgrid/mail' import sgMail from '@sendgrid/mail'
if (process.env.NODE_ENV === 'development') require('dotenv').config()
sgMail.setApiKey('' + process.env.SENDGRID_API_KEY) sgMail.setApiKey('' + process.env.SENDGRID_API_KEY)
const sendToken = (username: string, email: string, token: string) => { const sendToken = (username: string, email: string, token: string) => {

View File

@ -6,6 +6,8 @@ import { ApolloContextType, JwtPayloadType } from './types'
import { ApolloServer, makeExecutableSchema } from 'apollo-server-express' import { ApolloServer, makeExecutableSchema } from 'apollo-server-express'
import { PrismaClient } from '@prisma/client' import { PrismaClient } from '@prisma/client'
if (process.env.NODE_ENV === 'development') require('dotenv').config()
const app = express() const app = express()
app.use( app.use(