Simplify docker-compose for Dokploy - API only
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { Resend } from 'resend';
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||
// Only initialize Resend if API key is provided
|
||||
const resend = process.env.RESEND_API_KEY
|
||||
? new Resend(process.env.RESEND_API_KEY)
|
||||
: null;
|
||||
|
||||
const FROM_EMAIL = process.env.FROM_EMAIL || 'noreply@donovankelly.xyz';
|
||||
const APP_URL = process.env.APP_URL || 'https://todo.donovankelly.xyz';
|
||||
@@ -14,6 +17,12 @@ export async function sendInviteEmail(params: {
|
||||
const { to, name, token, inviterName } = params;
|
||||
const setupUrl = `${APP_URL}/setup?token=${token}`;
|
||||
|
||||
if (!resend) {
|
||||
console.log(`[DEV] Would send invite email to ${to}`);
|
||||
console.log(`[DEV] Setup URL: ${setupUrl}`);
|
||||
return { id: 'dev-email-id' };
|
||||
}
|
||||
|
||||
const { data, error } = await resend.emails.send({
|
||||
from: FROM_EMAIL,
|
||||
to,
|
||||
@@ -73,6 +82,11 @@ export async function sendReminderEmail(params: {
|
||||
}) {
|
||||
const { to, taskTitle, dueDate, taskUrl } = params;
|
||||
|
||||
if (!resend) {
|
||||
console.log(`[DEV] Would send reminder email to ${to} for task: ${taskTitle}`);
|
||||
return { id: 'dev-email-id' };
|
||||
}
|
||||
|
||||
const { data, error } = await resend.emails.send({
|
||||
from: FROM_EMAIL,
|
||||
to,
|
||||
|
||||
@@ -23,10 +23,10 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
})
|
||||
|
||||
// Get single project with sections and task counts
|
||||
.get('/:id', async ({ params, user, set }) => {
|
||||
.get('/:projectId', async ({ params, user, set }) => {
|
||||
const project = await db.query.projects.findFirst({
|
||||
where: and(
|
||||
eq(projects.id, params.id),
|
||||
eq(projects.id, params.projectId),
|
||||
eq(projects.userId, (user as User).id)
|
||||
),
|
||||
with: {
|
||||
@@ -47,7 +47,7 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
return project;
|
||||
}, {
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
projectId: t.String(),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -70,10 +70,10 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
})
|
||||
|
||||
// Update project
|
||||
.patch('/:id', async ({ params, body, user, set }) => {
|
||||
.patch('/:projectId', async ({ params, body, user, set }) => {
|
||||
const existing = await db.query.projects.findFirst({
|
||||
where: and(
|
||||
eq(projects.id, params.id),
|
||||
eq(projects.id, params.projectId),
|
||||
eq(projects.userId, (user as User).id)
|
||||
),
|
||||
});
|
||||
@@ -95,13 +95,13 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
...body,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(projects.id, params.id))
|
||||
.where(eq(projects.id, params.projectId))
|
||||
.returning();
|
||||
|
||||
return updated;
|
||||
}, {
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
projectId: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
name: t.Optional(t.String({ minLength: 1, maxLength: 100 })),
|
||||
@@ -114,10 +114,10 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
})
|
||||
|
||||
// Delete project
|
||||
.delete('/:id', async ({ params, user, set }) => {
|
||||
.delete('/:projectId', async ({ params, user, set }) => {
|
||||
const existing = await db.query.projects.findFirst({
|
||||
where: and(
|
||||
eq(projects.id, params.id),
|
||||
eq(projects.id, params.projectId),
|
||||
eq(projects.userId, (user as User).id)
|
||||
),
|
||||
});
|
||||
@@ -132,23 +132,23 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
throw new Error('Cannot delete inbox project');
|
||||
}
|
||||
|
||||
await db.delete(projects).where(eq(projects.id, params.id));
|
||||
await db.delete(projects).where(eq(projects.id, params.projectId));
|
||||
|
||||
return { success: true };
|
||||
}, {
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
projectId: t.String(),
|
||||
}),
|
||||
})
|
||||
|
||||
// ============= SECTIONS =============
|
||||
|
||||
// Create section in project
|
||||
.post('/:id/sections', async ({ params, body, user, set }) => {
|
||||
.post('/:projectId/sections', async ({ params, body, user, set }) => {
|
||||
// Verify project ownership
|
||||
const project = await db.query.projects.findFirst({
|
||||
where: and(
|
||||
eq(projects.id, params.id),
|
||||
eq(projects.id, params.projectId),
|
||||
eq(projects.userId, (user as User).id)
|
||||
),
|
||||
});
|
||||
@@ -159,7 +159,7 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
}
|
||||
|
||||
const [section] = await db.insert(sections).values({
|
||||
projectId: params.id,
|
||||
projectId: params.projectId,
|
||||
name: body.name,
|
||||
sortOrder: body.sortOrder,
|
||||
}).returning();
|
||||
@@ -167,7 +167,7 @@ export const projectRoutes = new Elysia({ prefix: '/projects' })
|
||||
return section;
|
||||
}, {
|
||||
params: t.Object({
|
||||
id: t.String(),
|
||||
projectId: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
name: t.String({ minLength: 1, maxLength: 100 }),
|
||||
|
||||
Reference in New Issue
Block a user