Restructure: rename to Pulse and move app to root
- Renamed project from PSA-Utils to Pulse - Moved all app files from autotask-app/ to root - Updated package.json name to 'pulse' - Updated Docker container names to pulse-app and pulse-redis - Updated Docker network name to pulse-network
This commit is contained in:
parent
f429f3af54
commit
3c3124d8c9
117 changed files with 8433 additions and 239 deletions
50
app/api/tasks/route.ts
Normal file
50
app/api/tasks/route.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getAutotaskClient } from '@/lib/services/autotask-factory';
|
||||
import { Task } from '@/lib/types/autotask';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const client = getAutotaskClient();
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
const resourceId = searchParams.get('resourceId');
|
||||
const projectId = searchParams.get('projectId');
|
||||
|
||||
let tasks: Task[] = [];
|
||||
|
||||
if (resourceId) {
|
||||
tasks = await client.getTasksByResource(parseInt(resourceId));
|
||||
} else if (projectId) {
|
||||
tasks = await client.getTasksByProject(parseInt(projectId));
|
||||
} else {
|
||||
// Get all open tasks
|
||||
tasks = await client.queryEntity<Task>('Tasks', {
|
||||
filter: [{ op: 'noteq', field: 'status', value: 5 }],
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({ tasks });
|
||||
} catch (error) {
|
||||
console.error('Error fetching tasks:', error);
|
||||
return NextResponse.json(
|
||||
{ error: error instanceof Error ? error.message : 'Failed to fetch tasks' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const client = getAutotaskClient();
|
||||
const body = await request.json();
|
||||
|
||||
const task = await client.createTask(body);
|
||||
|
||||
return NextResponse.json({ task });
|
||||
} catch (error) {
|
||||
console.error('Error creating task:', error);
|
||||
return NextResponse.json(
|
||||
{ error: error instanceof Error ? error.message : 'Failed to create task' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue