fix email env

This commit is contained in:
Emily
2024-06-02 16:01:57 +02:00
parent 49064f709d
commit 6fb3c9c652
6 changed files with 75 additions and 39 deletions

View File

@@ -32,6 +32,10 @@ export default defineNuxtConfig({
AI_ORG: process.env.AI_ORG,
AI_PROJECT: process.env.AI_PROJECT,
AI_KEY: process.env.AI_KEY,
EMAIL_SERVICE: process.env.EMAIL_SERVICE,
EMAIL_HOST: process.env.EMAIL_HOST,
EMAIL_USER: process.env.EMAIL_USER,
EMAIL_PASS: process.env.EMAIL_PASS,
AUTH_JWT_SECRET: process.env.AUTH_JWT_SECRET,
GOOGLE_AUTH_CLIENT_ID: process.env.GOOGLE_AUTH_CLIENT_ID,
GOOGLE_AUTH_CLIENT_SECRET: process.env.GOOGLE_AUTH_CLIENT_SECRET,

View File

@@ -2,7 +2,7 @@
import { OAuth2Client } from 'google-auth-library';
import { createUserJwt } from '~/server/AuthManager';
import { UserModel } from '@schema/UserSchema';
import { sendWelcomeEmail } from '@services/EmailService';
import EmailService from '@services/EmailService';
const { GOOGLE_AUTH_CLIENT_SECRET, GOOGLE_AUTH_CLIENT_ID } = useRuntimeConfig()
@@ -47,7 +47,7 @@ export default defineEventHandler(async event => {
const savedUser = await newUser.save();
setImmediate(() => {
if (payload.email) sendWelcomeEmail(payload.email);
if (payload.email) EmailService.sendWelcomeEmail(payload.email);
});
return { error: false, access_token: createUserJwt({ email: savedUser.email, name: savedUser.name }) }

View File

@@ -1,5 +1,7 @@
import mongoose from "mongoose";
import { Redis } from "~/server/services/CacheService";
import EmailService from '@services/EmailService';
const config = useRuntimeConfig();
let connection: mongoose.Mongoose;
@@ -7,8 +9,16 @@ export default async () => {
console.log('[SERVER] Initializing');
EmailService.createTransport(
config.EMAIL_SERVICE,
config.EMAIL_HOST,
config.EMAIL_USER,
config.EMAIL_PASS,
);
if (!connection || connection.connection.readyState == mongoose.ConnectionStates.disconnected) {
console.log('[DATABASE] Connecting');
console.log('[DATABASE] Connecting');
connection = await mongoose.connect(config.MONGO_CONNECTION_STRING);
console.log('[DATABASE] Connected');
}