kleneway / jacob

Just Another Coding Bot
https://jacb.ai
Apache License 2.0
0 stars 0 forks source link

Implement CRUD Endpoints for Todos #4

Closed kleneway closed 1 day ago

kleneway commented 1 month ago

Title: Implement CRUD Endpoints for Todos

Description:

We need to create CRUD endpoints for managing Todos. The endpoints should follow the structure and conventions used in the existing Task API. The Todos table schema is as follows:

export class TodosTable extends BaseTable {
  readonly table = "todos";
  columns = this.setColumns((t) => ({
    id: t.varchar(255).primaryKey(),
    description: t.text(),
    name: t.text(),
    status: t.enum(TodoStatus),
    issueId: t.bigint().nullable(),
    stepsToAddressIssue: t.text().nullable(),
    issueQualityScore: t.float().nullable(),
    commitTitle: t.text().nullable(),
    filesToCreate: t.array(t.text()).nullable(),
    filesToUpdate: t.array(t.text()).nullable(),
    ...t.timestamps(),
  }));
}

Requirements:

Example Code:

Use the following example code for the Task API as a reference for implementing the Todos API:

import { z } from "zod";
import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";

// Task interface
export interface Task {
  id: string;
  name: string;
  completed: boolean;
}

// Create the tRPC router
export const taskRouter = createTRPCRouter({
  // Get all tasks
  getAll: protectedProcedure.query(async () => {
    return [] as Task[]; // Replace with actual database query
  }),

  // Create a new task
  create: protectedProcedure
    .input(z.object({ name: z.string() }))
    .mutation(async ({ input }) => {
      const newTask: Task = { id: "task-1", ...input, completed: false };
      return newTask; // Replace with actual database creation
    }),

  // Update a task
  update: protectedProcedure
    .input(z.object({ id: z.string(), completed: z.boolean() }))
    .mutation(async ({ input }) => {
      return null as Task | null; // Replace with actual database update
    }),
});

New Files:

Acceptance Criteria:

@jacob-ai-bot

Steps to Address Issue: 1. Create a new file 'todos.ts' in the '/src/server/api/routers' directory. 2. Define CRUD endpoints for Todos, ensuring they accept and return data conforming to the Todos table schema. 3. Implement the Create endpoint to accept 'description', 'name', and 'status' as required fields. 4. Implement the Read endpoint to return all Todos without filtering or sorting. 5. Implement the Update endpoint to allow updating all fields of a Todo. 6. Implement the Delete endpoint to perform a hard delete on a Todo. 7. Follow the structure and conventions of the existing Task API example code provided.

Files to Create: src/server/api/routers/todos.ts

task assigned to: @jacob-ai-bot

jacob-local-kevin[bot] commented 1 month ago

JACoB here...

You mentioned me on this issue and I am busy taking a look at it.

I'll continue to comment on this issue with status as I make progress.

jacob-local-kevin[bot] commented 1 month ago

JACoB here...

You mentioned me on this issue and I am busy taking a look at it.

I'll continue to comment on this issue with status as I make progress.

jacob-local-kevin[bot] commented 1 month ago

Update

I've completed my initial work on this issue and have created a pull request: Create /src/server/api/routers/todos.ts.

The changes currently result in an error, so I'll be making some additional changes before it is ready to merge.

jacob-local-kevin[bot] commented 1 month ago

Update

I've updated this pull request: Create /src/server/api/routers/todos.ts.

The changes currently result in an error, so I'll be making some additional changes before it is ready to merge.