Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 62 additions & 63 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,63 +1,62 @@
# ─── Dependencies ─────────────────────────────────────
node_modules/
.pnp
.pnp.js

./packages/*/node_modules/
./apps/*/node_modules/
./node_modules/
/node_modules/
# ─── Build outputs ────────────────────────────────────
dist/
build/
.next/
out/
*.tsbuildinfo

# ─── Environment files ────────────────────────────────
# Keep .env.example tracked
!.env.example
!**/.env.example

# ─── Turbo ────────────────────────────────────────────
.turbo/

# ─── Prisma ───────────────────────────────────────────
apps/api/prisma/dev.db
apps/api/prisma/dev.db-journal

# ─── Logs ─────────────────────────────────────────────
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# ─── OS files ─────────────────────────────────────────
.DS_Store
Thumbs.db
desktop.ini

# ─── IDE ──────────────────────────────────────────────
.vscode/
.idea/
*.swp
*.swo
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# ─── Testing ──────────────────────────────────────────
coverage/
.nyc_output/
jest-results/

# ─── Misc ─────────────────────────────────────────────
*.pem
.cache/
tmp/
temp/
config.bat
# ─── Dependencies ─────────────────────────────────────
node_modules/
.pnp
.pnp.js

./packages/*/node_modules/
./apps/*/node_modules/
./node_modules/
/node_modules/
# ─── Build outputs ────────────────────────────────────
dist/
build/
.next/
out/
*.tsbuildinfo

# ─── Environment files ────────────────────────────────
# Keep .env.example tracked
!.env.example
!**/.env.example

# ─── Turbo ────────────────────────────────────────────
.turbo/

# ─── Prisma ───────────────────────────────────────────
apps/api/prisma/dev.db
apps/api/prisma/dev.db-journal

# ─── Logs ─────────────────────────────────────────────
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# ─── OS files ─────────────────────────────────────────
.DS_Store
Thumbs.db
desktop.ini

# ─── IDE ──────────────────────────────────────────────
.vscode/
.idea/
*.swp
*.swo
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# ─── Testing ──────────────────────────────────────────
coverage/
.nyc_output/
jest-results/

# ─── Misc ─────────────────────────────────────────────
*.pem
.cache/
tmp/
temp/
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "prompts" ADD COLUMN "deletedAt" TIMESTAMP(3);
1 change: 1 addition & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ model Prompt {
tags String[] @default([])
workspaceId String
isPublic Boolean @default(false)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

Expand Down
26 changes: 26 additions & 0 deletions apps/api/src/prompts/dto/create-prompt.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
IsArray,
IsNotEmpty,
IsOptional,
IsString,
MaxLength,
} from 'class-validator';
import { Transform } from 'class-transformer';

export class CreatePromptDto {
@IsString()
@IsNotEmpty()
@MaxLength(100)
@Transform(({ value }: { value: string }) => value.trim())
name: string;

@IsString()
@IsOptional()
@MaxLength(500)
description?: string;

@IsArray()
@IsString({ each: true })
@IsOptional()
tags?: string[];
}
17 changes: 17 additions & 0 deletions apps/api/src/prompts/dto/list-prompts-query.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Type } from 'class-transformer';
import { IsInt, IsOptional, Max, Min } from 'class-validator';

export class ListPromptsQueryDto {
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
page: number = 1;

@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(100)
limit: number = 20;
}
55 changes: 55 additions & 0 deletions apps/api/src/prompts/prompts.controller.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Query,
UseGuards,
} from '@nestjs/common';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import type { User } from '@prisma/client';
import { DiffService } from './diff.service';
import { PromptsService } from './prompts.service';
import { CreatePromptDto } from './dto/create-prompt.dto';
import { ListPromptsQueryDto } from './dto/list-prompts-query.dto';
import { Controller, Get, Param, Query } from '@nestjs/common';
import { DiffService } from './diff.service';
import { IsString, IsNotEmpty } from 'class-validator';
Expand All @@ -12,6 +29,44 @@ class DiffQueryDto {
to: string;
}

@UseGuards(JwtAuthGuard)
@Controller()
export class PromptsController {
constructor(
private readonly promptsService: PromptsService,
private readonly diffService: DiffService,
) {}

@Post('workspaces/:workspaceId/prompts')
create(
@Param('workspaceId') workspaceId: string,
@Body() dto: CreatePromptDto,
@CurrentUser() user: User,
) {
return this.promptsService.create(workspaceId, user.id, dto);
}

@Get('workspaces/:workspaceId/prompts')
list(
@Param('workspaceId') workspaceId: string,
@Query() query: ListPromptsQueryDto,
@CurrentUser() user: User,
) {
return this.promptsService.list(workspaceId, user.id, query);
}

@Get('prompts/:id')
findOne(@Param('id') id: string) {
return this.promptsService.findOne(id);
}

@Delete('prompts/:id')
softDelete(@Param('id') id: string, @CurrentUser() user: User) {
return this.promptsService.softDelete(id, user.id);
}

@Get('prompts/:id/diff')
diff(@Param('id') id: string, @Query() query: DiffQueryDto) {
@Controller('prompts')
export class PromptsController {
constructor(private readonly diffService: DiffService) {}
Expand Down
Loading
Loading