### Example GET Request (HTTP) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md An example of a GET request to the test endpoint, illustrating how to interact with the API. ```http GET /api/v1/tests ``` -------------------------------- ### Production Build and Start (Bash) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md Commands to build the TypeScript project for production and start the production server. ```bash npm run build npm start ``` -------------------------------- ### Clone and Install Dependencies (Bash) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md Commands to clone the repository, navigate into the directory, and install project dependencies using npm. ```bash git clone cd api npm install ``` -------------------------------- ### Environment Configuration (Env) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md Example of an .env file setup, specifying required environment variables for the application, including port, database connection, and JWT secrets. ```env PORT=5050 NODE_ENV=development DATABASE_URL=postgresql://username:password@localhost:5432/your_database JWT_SECRET=your-super-secret-jwt-key-min-32-chars JWT_REFRESH_SECRET=your-super-secret-refresh-key-min-32-chars API_PREFIX=/api/v1 ``` -------------------------------- ### Start Development Server (Bash) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md Command to start the development server, which includes hot reloading enabled by nodemon. ```bash npm run dev ``` -------------------------------- ### Prisma Database Setup (Bash) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md Commands for setting up the PostgreSQL database using Prisma, including generating the Prisma client, running migrations, and optionally seeding the database. ```bash npx prisma generate npx prisma migrate dev --name init npx prisma db seed ``` -------------------------------- ### GET /api/v1/users/hello Source: https://context7.com/ahsan90/express-starter-kit/llms.txt A simple GET endpoint that demonstrates basic module functionality and returns a greeting message. ```APIDOC ## GET /api/v1/users/hello ### Description Simple GET endpoint demonstrating basic module functionality. ### Method GET ### Endpoint /api/v1/users/hello ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET http://localhost:3000/api/v1/users/hello \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200 OK) - **message** (string) - A greeting message from the User service. #### Response Example ```json { "message": "Hello from User service" } ``` ``` -------------------------------- ### Available Scripts (Bash) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md A list of available npm scripts for development (dev, build, start), module generation CLI, database operations with Prisma, and log monitoring. ```bash # Development npm run dev # Start development server with nodemon npm run build # Build TypeScript to JavaScript npm start # Start production server # Module Generator CLI npx g # Generate basic module npx g --crud # Generate full CRUD module npx g --remove # Remove a module npx g --help # Show CLI help # Database npx prisma generate # Generate Prisma client npx prisma migrate dev # Run migrations in development npx prisma studio # Open Prisma Studio npx prisma db push # Push schema changes to database # Logging tail -f logs/*.log # Monitor application logs ``` -------------------------------- ### Dockerfile for Containerization Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md A Dockerfile to containerize the Express.js application, including installing production dependencies, copying code, building the project, and exposing the application port. ```dockerfile FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . RUN npm run build EXPOSE 5050 CMD ["npm", "start"] ``` -------------------------------- ### Initialize Express Server with Socket.IO and DB Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Starts the Express server, automatically connecting to the database, initializing Socket.IO, and setting up graceful shutdown handlers for SIGINT and SIGTERM signals. It logs server status, database connection success, and system information. ```typescript import { startServer } from './server'; // Automatically connects to database, initializes Socket.IO, and starts listening startServer(); // Console output: // Server running on port 3000 // Database connected successfully // System Info: { // os: 'Linux', // arch: 'x64', // memory: { total: '16.00 GB', free: '8.45 GB' }, // cpus: 8, // hostname: 'api-server', // uptime: 1234567 // } // Graceful shutdown on SIGINT or SIGTERM // Ctrl+C pressed // Received SIGINT signal. Shutting down gracefully... // [Server closed] ``` -------------------------------- ### Async In-Memory Caching with Node-Cache Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Demonstrates caching operations using an async wrapper for node-cache. Supports get, set (with TTL), delete, check existence, get or set, bulk operations, increment/decrement, statistics, and flushing the cache. Requires the async-node-cache library. ```typescript import { asyncNodeCache } from './lib/node-cache'; // Get from cache const user = await asyncNodeCache.get('user:123'); // Set with default TTL (3600 seconds) await asyncNodeCache.set('user:123', { id: '123', name: 'John' }); // Set with custom TTL (600 seconds) await asyncNodeCache.set('session:abc', sessionData, 600); // Delete from cache await asyncNodeCache.delete('user:123'); // Check if key exists const exists = await asyncNodeCache.has('user:123'); // Get or set pattern (fetch from DB if not in cache) const user = await asyncNodeCache.getOrSet( 'user:123', async () => { return await prisma.user.findUnique({ where: { id: '123' } }); }, 3600 ); // Bulk operations await asyncNodeCache.mset({ 'user:1': { id: '1', name: 'Alice' }, 'user:2': { id: '2', name: 'Bob' } }, 1800); const users = await asyncNodeCache.mget(['user:1', 'user:2']); // { 'user:1': {...}, 'user:2': {...} } // Increment/decrement await asyncNodeCache.set('page:views', 100); await asyncNodeCache.increment('page:views', 1); // 101 await asyncNodeCache.decrement('page:views', 5); // 96 // Cache statistics const stats = await asyncNodeCache.stats(); // { hits: 150, misses: 25, keys: 50, ksize: 1024, vsize: 51200 } // Flush all cache await asyncNodeCache.flush(); ``` -------------------------------- ### GET /api/v1/tests Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Retrieves all test records from the database. This endpoint is used to fetch a list of all available tests. ```APIDOC ## GET /api/v1/tests ### Description Retrieves all test records from the database. ### Method GET ### Endpoint /api/v1/tests ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET http://localhost:3000/api/v1/tests \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the test. - **name** (string) - The name of the test. - **description** (string) - A description of the test. - **createdAt** (string) - The timestamp when the test was created. #### Response Example ```json [ { "id": "1", "name": "Sample Test", "description": "Test description", "createdAt": "2025-11-13T10:30:00.000Z" }, { "id": "2", "name": "Another Test", "description": "Another description", "createdAt": "2025-11-13T11:45:00.000Z" } ] ``` #### Error Response (500) - **status** (string) - Indicates an error occurred. - **message** (string) - A message describing the internal server error. ```json { "status": "error", "message": "Internal server error" } ``` ``` -------------------------------- ### GET /api/v1/tests/:id Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Retrieves a specific test record by its unique identifier. Use this endpoint to get details of a single test. ```APIDOC ## GET /api/v1/tests/:id ### Description Retrieves a specific test record by its unique identifier. ### Method GET ### Endpoint /api/v1/tests/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the test to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET http://localhost:3000/api/v1/tests/123 \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the test. - **name** (string) - The name of the test. - **description** (string) - A description of the test. - **createdAt** (string) - The timestamp when the test was created. - **updatedAt** (string) - The timestamp when the test was last updated. #### Response Example ```json { "id": "123", "name": "Specific Test", "description": "Detailed test information", "createdAt": "2025-11-13T10:30:00.000Z", "updatedAt": "2025-11-13T12:00:00.000Z" } ``` #### Error Response (404) - **status** (string) - Indicates an error occurred. - **message** (string) - A message indicating the test was not found. ```json { "status": "error", "message": "Test not found" } ``` ``` -------------------------------- ### Generate Express Modules using CLI Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Command-line interface for generating feature modules with a consistent architecture. Supports basic module creation, full CRUD operations, and removing modules. Updates the main API file automatically. Requires the 'g' command to be installed. ```bash # Generate basic module with single hello endpoint npx g product # Creates: src/modules/product/ # - product.controller.ts (with hello route) # - product.service.ts (with hello method) # - product.routes.ts # - product.types.ts # - product.dtos.ts # - product.validators.ts # - product.middleware.ts # - product.utils.ts # Updates: src/api.ts (adds import and route registration) # Generate CRUD module with all REST operations npx g order --crud # Creates full CRUD module with 5 endpoints: # GET /api/v1/orders (get all) # GET /api/v1/orders/:id (get by id) # POST /api/v1/orders (create) # PUT /api/v1/orders/:id (update) # DELETE /api/v1/orders/:id (delete) # Short flag for CRUD npx g payment -c # Remove existing module npx g product --remove # Deletes: src/modules/product/ directory # Updates: src/api.ts (removes import and registration) # Short flag for remove npx g product -r # Console output on success: # ✅ Module 'product' created successfully # 📁 Files created in: src/modules/product/ # 🔗 Routes registered in: src/api.ts # 🚀 Module available at: http://localhost:3000/api/v1/products ``` -------------------------------- ### Update Dependencies (Bash) Source: https://github.com/ahsan90/express-starter-kit/blob/express-prisma-starter-kit/README.md Commands to update project dependencies to their latest versions and deploy database schema changes for production. ```bash npm update npx prisma migrate deploy # For production database updates ``` -------------------------------- ### JavaScript Socket.IO Client for Real-time Communication Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Provides a client-side JavaScript implementation for connecting to a Socket.IO server. It demonstrates how to establish a connection, send and receive messages, join and leave rooms, and disconnect. Requires the Socket.IO client library. ```javascript // Client-side (JavaScript) /* */ ``` -------------------------------- ### Log Application Events with Winston and Morgan Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Integrates Winston for detailed logging and Morgan for HTTP request logging. Supports various log levels (info, error, warn, debug) and can output logs to the console and files, including stack traces for errors. ```typescript import { logger } from './common/logger.middleware'; // Info logging logger.info('User created successfully'); logger.info(`Processing order ${orderId}`); // Error logging with stack trace try { await riskyOperation(); } catch (error) { logger.error('Failed to process payment', error); } // Warning logging logger.warn('Cache miss for key: user:123'); // Debug logging (development only) logger.debug('Request payload:', { userId: '123', action: 'update' }); // HTTP request logging (automatic via Morgan) // Console output: GET /api/v1/users 200 45ms - 1.23kb // File output (logs/requests/requests-2025-11-13.log): // 2025-11-13 14:30:15 [info]: GET /api/v1/users 200 45ms // Error file output (logs/errors/errors-2025-11-13.log): // 2025-11-13 14:35:20 [error]: Database connection failed // Error: Connection timeout after 5000ms // at Database.connect (/app/src/lib/db.ts:25:15) ``` -------------------------------- ### Interact with Prisma Database Client Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Utilizes the Prisma ORM with a singleton pattern for database access. Allows performing CRUD operations (find, create, update, delete) and transactional operations on database records. Supports complex queries with filtering and includes. ```typescript import { prisma } from './lib/db'; // Query database const users = await prisma.user.findMany({ where: { active: true }, include: { posts: true } }); // Create record const newUser = await prisma.user.create({ data: { email: 'user@example.com', name: 'John Doe', posts: { create: [ { title: 'First Post', content: 'Hello World' } ] } } }); // Update record const updated = await prisma.user.update({ where: { id: '123' }, data: { name: 'Jane Doe' } }); // Delete record await prisma.user.delete({ where: { id: '123' } }); // Transaction example const result = await prisma.$transaction(async (tx) => { const user = await tx.user.create({ data: { email: 'test@example.com' } }); const post = await tx.post.create({ data: { userId: user.id, title: 'Post' } }); return { user, post }; }); ``` -------------------------------- ### TypeScript Socket.IO Server for Real-time Communication Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Sets up a Socket.IO server using Node.js and http module to handle real-time bidirectional event-based communication. It listens for client connections, manages message broadcasting, and handles room joining/leaving. Requires http and socket.io packages. ```typescript // Server-side (src/server.ts) import { Server } from 'socket.io'; import http from 'http'; const httpServer = http.createServer(app); const io = new Server(httpServer, { cors: { origin: 'http://localhost:5050', credentials: true } }); io.on('connection', (socket) => { console.log(`Client connected: ${socket.id}`); // Listen for events socket.on('message', (data) => { console.log('Received:', data); // Emit to sender socket.emit('message', { echo: data }); // Broadcast to all clients io.emit('broadcast', { message: data, from: socket.id }); }); // Room operations socket.on('join-room', (room) => { socket.join(room); io.to(room).emit('user-joined', { userId: socket.id, room }); }); socket.on('leave-room', (room) => { socket.leave(room); io.to(room).emit('user-left', { userId: socket.id, room }); }); socket.on('disconnect', () => { console.log(`Client disconnected: ${socket.id}`); }); }); httpServer.listen(3000); ``` -------------------------------- ### POST /api/v1/tests Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Creates a new test record. Requires a request body with test details and performs validation. ```APIDOC ## POST /api/v1/tests ### Description Creates a new test record with validation. ### Method POST ### Endpoint /api/v1/tests ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - The name of the new test. - **description** (string) - Optional - A description for the new test. - **metadata** (object) - Optional - Additional metadata for the test. - **category** (string) - Optional - The category of the test. - **priority** (string) - Optional - The priority of the test. ### Request Example ```bash curl -X POST http://localhost:3000/api/v1/tests \ -H "Content-Type: application/json" \ -d '{ "name": "New Test", "description": "This is a new test entry", "metadata": { "category": "integration", "priority": "high" } }' ``` ### Response #### Success Response (201 Created) - **id** (string) - The unique identifier for the newly created test. - **name** (string) - The name of the new test. - **description** (string) - A description for the new test. - **metadata** (object) - Additional metadata for the test. - **createdAt** (string) - The timestamp when the test was created. #### Response Example ```json { "id": "456", "name": "New Test", "description": "This is a new test entry", "metadata": { "category": "integration", "priority": "high" }, "createdAt": "2025-11-13T14:20:00.000Z" } ``` #### Error Response (400 Bad Request) - **status** (string) - Indicates an error occurred. - **message** (string) - A message describing the validation failure. ```json { "status": "error", "message": "Validation failed: name is required" } ``` ``` -------------------------------- ### TypeScript Service Pattern for CRUD Operations with Caching Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Implements a service layer for managing 'test' entities using Prisma for database operations and asyncNodeCache for caching. It supports CRUD operations (getAll, getById, create, update, delete) with caching strategies for performance optimization and real-time data invalidation. Dependencies include prisma, asyncNodeCache, and a custom errorHandler. ```typescript // src/modules/test/test.service.ts import { prisma } from '../../lib/db'; import { asyncNodeCache } from '../../lib/node-cache'; import { createError } from '../../common/errorHandler'; class TestService { public getAllTests = async () => { // Try cache first const cached = await asyncNodeCache.get('tests:all'); if (cached) return cached; // Query database const tests = await prisma.test.findMany({ orderBy: { createdAt: 'desc' } }); // Cache result for 5 minutes await asyncNodeCache.set('tests:all', tests, 300); return tests; }; public getTestById = async (id: string) => { const cacheKey = `test:${id}`; // Get or set pattern const test = await asyncNodeCache.getOrSet( cacheKey, async () => { return await prisma.test.findUnique({ where: { id } }); }, 600 ); if (!test) { throw createError('Test not found', 404); } return test; }; public createTest = async (data: any) => { // Validate data if (!data.name) { throw createError('Name is required', 400); } // Create in database const test = await prisma.test.create({ data }); // Invalidate list cache await asyncNodeCache.delete('tests:all'); return test; }; public updateTest = async (id: string, data: any) => { const test = await prisma.test.findUnique({ where: { id } }); if (!test) { throw createError('Test not found', 404); } const updated = await prisma.test.update({ where: { id }, data }); // Invalidate caches await asyncNodeCache.mdelete([`test:${id}`, 'tests:all']); return updated; }; public deleteTest = async (id: string) => { const test = await prisma.test.findUnique({ where: { id } }); if (!test) { throw createError('Test not found', 404); } await prisma.test.delete({ where: { id } }); // Invalidate caches await asyncNodeCache.mdelete([`test:${id}`, 'tests:all']); return { message: 'Test deleted successfully' }; }; } export const testService = new TestService(); ``` -------------------------------- ### Implement Custom Application Error Handling Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Enables the creation and handling of custom application errors using `createError` and `AppError`. This system allows for meaningful error messages and appropriate HTTP status codes, which are then formatted by a centralized error handler. ```typescript import { createError, AppError } from './common/errorHandler'; // In controller or middleware if (!user) { throw createError('User not found', 404); } if (password !== hashedPassword) { throw createError('Invalid credentials', 401); } if (!req.body.email) { throw createError('Email is required', 400); } // Custom AppError class usage throw new AppError('Unauthorized access', 403); // Error handler automatically formats response: // { // "status": "error", // "message": "User not found" // } // In Express middleware chain app.use((req, res, next) => { try { // Your logic if (error) throw createError('Something went wrong', 500); } catch (error) { next(error); // Pass to centralized error handler } }); ``` -------------------------------- ### Express Controller Pattern with Error Handling Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Implements a standard controller pattern for Express.js applications. Each controller manages its routes, delegates logic to a service layer, and includes comprehensive try-catch blocks for error handling, passing errors to the Express 'next' function. ```typescript // src/modules/test/test.controller.ts import { Request, Response, NextFunction, Router } from 'express'; import { testService } from './test.service'; class TestController { public router: Router; constructor() { this.router = Router(); this.initializeRoutes(); } private initializeRoutes() { this.router.get('/', this.getAllTests); this.router.get('/:id', this.getTestById); this.router.post('/', this.createTest); this.router.put('/:id', this.updateTest); this.router.delete('/:id', this.deleteTest); } private getAllTests = async (req: Request, res: Response, next: NextFunction) => { try { const tests = await testService.getAllTests(); res.status(200).json(tests); } catch (error) { next(error); } }; private getTestById = async (req: Request, res: Response, next: NextFunction) => { try { const { id } = req.params; const test = await testService.getTestById(id); res.status(200).json(test); } catch (error) { next(error); } }; private createTest = async (req: Request, res: Response, next: NextFunction) => { try { const test = await testService.createTest(req.body); res.status(201).json(test); } catch (error) { next(error); } }; private updateTest = async (req: Request, res: Response, next: NextFunction) => { try { const { id } = req.params; const test = await testService.updateTest(id, req.body); res.status(200).json(test); } catch (error) { next(error); } }; private deleteTest = async (req: Request, res: Response, next: NextFunction) => { try { const { id } = req.params; const result = await testService.deleteTest(id); res.status(200).json(result); } catch (error) { next(error); } }; } export const testController = new TestController(); ``` -------------------------------- ### Prisma Schema Definition for Database Models Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Defines database models (User, Profile, Post, Tag) and their relationships using Prisma schema. This schema is used to generate a type-safe database client and manage migrations. It includes field types, constraints, and relations essential for data persistence with PostgreSQL. ```prisma // prisma/schema.prisma generator client { provider = "prisma-client-js" output = "../src/generated/prisma" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id String @id @default(uuid()) email String @unique name String? password String posts Post[] profile Profile? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@index ([email]) } model Profile { id String @id @default(uuid()) bio String? avatar String? userId String @unique user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model Post { id String @id @default(uuid()) title String content String? published Boolean @default(false) authorId String author User @relation(fields: [authorId], references: [id], onDelete: Cascade) tags Tag[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@index ([authorId]) @@index ([published]) } model Tag { id String @id @default(uuid()) name String @unique posts Post[] } // After defining schema, run migrations: // npx prisma migrate dev --name init // npx prisma generate ``` -------------------------------- ### Access Typed Environment Variables Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Provides access to validated environment variables with type safety using the `env` object. It ensures that required variables are present and meet specific criteria (e.g., string length, URI format) at application startup. ```typescript import { env } from './lib/env'; // All environment variables are validated at startup const port = env.PORT; // number (default: 3000) const nodeEnv = env.NODE_ENV; // 'development' | 'production' | 'test' const dbUrl = env.DATABASE_URL; // string (required, validated as URI) const jwtSecret = env.JWT_SECRET; // string (min 32 chars, required) const jwtRefreshSecret = env.JWT_REFRESH_SECRET; // string (min 32 chars, required) const apiPrefix = env.API_PREFIX; // string (default: '/api/v1') // Example .env file: // PORT=3000 // NODE_ENV=development // DATABASE_URL=postgresql://user:password@localhost:5432/mydb // JWT_SECRET=your-super-secret-jwt-key-minimum-32-characters-long // JWT_REFRESH_SECRET=your-super-secret-refresh-key-minimum-32-characters // API_PREFIX=/api/v1 // Validation error if required variables missing: // Error: "DATABASE_URL" is required // Error: "JWT_SECRET" length must be at least 32 characters long ``` -------------------------------- ### PUT /api/v1/tests/:id Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Updates an existing test record by its unique identifier. Requires a request body with updated test details. ```APIDOC ## PUT /api/v1/tests/:id ### Description Updates an existing test record by ID. ### Method PUT ### Endpoint /api/v1/tests/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the test to update. #### Query Parameters None #### Request Body - **name** (string) - Optional - The updated name of the test. - **description** (string) - Optional - The updated description of the test. - **metadata** (object) - Optional - The updated metadata for the test. - **category** (string) - Optional - The updated category of the test. - **priority** (string) - Optional - The updated priority of the test. ### Request Example ```bash curl -X PUT http://localhost:3000/api/v1/tests/456 \ -H "Content-Type: application/json" \ -d '{ "name": "Updated Test Name", "description": "Updated description with new information", "metadata": { "category": "unit", "priority": "medium" } }' ``` ### Response #### Success Response (200 OK) - **id** (string) - The unique identifier for the updated test. - **name** (string) - The updated name of the test. - **description** (string) - The updated description of the test. - **metadata** (object) - The updated metadata for the test. - **updatedAt** (string) - The timestamp when the test was last updated. #### Response Example ```json { "id": "456", "name": "Updated Test Name", "description": "Updated description with new information", "metadata": { "category": "unit", "priority": "medium" }, "updatedAt": "2025-11-13T15:30:00.000Z" } ``` #### Error Response (404) - **status** (string) - Indicates an error occurred. - **message** (string) - A message indicating the test was not found. ```json { "status": "error", "message": "Test not found" } ``` ``` -------------------------------- ### DELETE /api/v1/tests/:id Source: https://context7.com/ahsan90/express-starter-kit/llms.txt Deletes a test record from the database by its unique identifier. ```APIDOC ## DELETE /api/v1/tests/:id ### Description Deletes a test record from the database. ### Method DELETE ### Endpoint /api/v1/tests/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the test to delete. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X DELETE http://localhost:3000/api/v1/tests/456 \ -H "Content-Type: application/json" ``` ### Response #### Success Response (200 OK) - **message** (string) - A confirmation message indicating the test was deleted successfully. #### Response Example ```json { "message": "Test deleted successfully" } ``` #### Error Response (404) - **status** (string) - Indicates an error occurred. - **message** (string) - A message indicating the test was not found. ```json { "status": "error", "message": "Test not found" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.