chore: move backend to hono + typescript (#558)
* feat: setup secure presigned uploads and downloads * clean up * update lock * Get presigned url finally working * 557: Migrate backend to hono + ts * chore: update Dockerfile and package.json for backend configuration * add dev command * remove unused packages * Enhance backend API and frontend components for course management - Updated CORS configuration in the backend to allow specific methods and headers. - Refactored lesson download endpoint to use a new route for PDF downloads. - Removed unused certificate download functionality from the lesson router. - Updated frontend components to reflect changes in API endpoints and improve video upload functionality. - Introduced new video upload component and adjusted video handling in lesson materials. - Cleaned up unnecessary imports and optimized component structure for better performance. * PR cleanups * Enhance email configuration by adding SMTP_SENDER environment variable - Updated docker-compose.yaml to include SMTP_SENDER. - Modified Dockerfile to accept SMTP_SENDER as an argument. - Updated environment schema in env.ts to define SMTP_SENDER as optional. - Adjusted mail service to use SMTP_SENDER for the email 'from' field. - Updated documentation to reflect the new SMTP_SENDER variable. * Remove debug log statement from sendEmail function --------- Co-authored-by: Iniubong Obonguko <iniubongobonguko2018@gmail.com>
This commit is contained in:
co-authored by
Iniubong Obonguko
parent
9eb7b01587
commit
82be557a42
+1
@@ -1,5 +1,6 @@
|
||||
import { Configuration, OpenAIApi } from 'openai-edge';
|
||||
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
||||
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
// Create an OpenAI API client (that's edge friendly!)
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, content, orgName, exerciseTitle } = await request.json();
|
||||
|
||||
if (!to || !content || !orgName) {
|
||||
@@ -17,7 +17,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
@@ -1,11 +1,16 @@
|
||||
import { getServerSupabase } from '$lib/utils/functions/supabase.server';
|
||||
import { getFeedForNotification } from '$lib/utils/services/newsfeed/index';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { getServerSupabase } from '$lib/utils/functions/supabase.server';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
const supabase = getServerSupabase();
|
||||
|
||||
const sendEmailNotification = async (feedId: string, authorId: string, comment?: string) => {
|
||||
const sendEmailNotification = async (
|
||||
sFetch: typeof fetch,
|
||||
feedId: string,
|
||||
authorId: string,
|
||||
comment?: string
|
||||
) => {
|
||||
const feed = await getFeedForNotification({
|
||||
supabase,
|
||||
feedId,
|
||||
@@ -34,7 +39,7 @@ const sendEmailNotification = async (feedId: string, authorId: string, comment?:
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(sFetch)(emailData);
|
||||
|
||||
// dont continue
|
||||
return;
|
||||
@@ -62,10 +67,10 @@ const sendEmailNotification = async (feedId: string, authorId: string, comment?:
|
||||
console.log('Sending emails to all students', feed.courseMembers.length);
|
||||
|
||||
// This is the email sending function with a loop
|
||||
await sendEmail(emailsData);
|
||||
await sendEmail(sFetch)(emailsData);
|
||||
};
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { authorId, feedId, comment } = await request.json();
|
||||
console.log('/POST api/email/course/newsfeed');
|
||||
|
||||
@@ -73,7 +78,7 @@ export async function POST({ request }) {
|
||||
return json({ success: false, message: 'Missing required fields' }, { status: 400 });
|
||||
}
|
||||
|
||||
await sendEmailNotification(feedId, authorId, comment);
|
||||
await sendEmailNotification(fetch, feedId, authorId, comment);
|
||||
// TODO: Support sending to other platforms like telegram and discord
|
||||
// sendDiscordNotification(); sendTelegramNotification();
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import sendEmail from '$mail/sendEmail';
|
||||
|
||||
// const supabase = getSupabase();
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, courseName, teacherEmail, studentFullname, orgName } = await request.json();
|
||||
// const accessToken = request.headers.get('Authorization') || '';
|
||||
console.log(
|
||||
@@ -48,7 +48,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
// Sends email to student when they successfully join a course
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, orgName, courseName } = await request.json();
|
||||
console.log('/POST api/email/course/student_welcome', to, orgName);
|
||||
|
||||
@@ -25,7 +25,7 @@ export async function POST({ request }) {
|
||||
`
|
||||
}
|
||||
];
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, content, orgName } = await request.json();
|
||||
|
||||
if (!to || !content || !orgName) {
|
||||
@@ -17,7 +17,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, courseName, studentEmail, studentFullname } = await request.json();
|
||||
console.log(
|
||||
'/POST api/email/course/teacher_student_buycourse',
|
||||
@@ -31,7 +31,7 @@ export async function POST({ request }) {
|
||||
`
|
||||
}
|
||||
];
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, courseName, studentName, studentEmail } = await request.json();
|
||||
console.log('/POST api/email/course/teacher_student_joined', to, courseName);
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, name, orgName, courseName, orgSiteName } = await request.json();
|
||||
console.log('/POST api/email/course/teacher_welcome', to, name, orgName);
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
// API to send invite to teacher
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const body = await request.json();
|
||||
const { org, email } = body;
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function POST({ request }) {
|
||||
`
|
||||
}
|
||||
];
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, profileId, orgSiteName, fullname } = await request.json();
|
||||
console.log('/POST api/email/verify_email', to, profileId);
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import sendEmail from '$mail/sendEmail';
|
||||
|
||||
export async function POST({ request }) {
|
||||
export async function POST({ fetch, request }) {
|
||||
const { to, name } = await request.json();
|
||||
console.log('/POST api/email/welcome', to, name);
|
||||
|
||||
@@ -33,7 +33,7 @@ export async function POST({ request }) {
|
||||
}
|
||||
];
|
||||
|
||||
await sendEmail(emailData);
|
||||
await sendEmail(fetch)(emailData);
|
||||
|
||||
return json({
|
||||
success: true,
|
||||
Reference in New Issue
Block a user