بنقرة واحدة
endpoint
Implement REST API endpoints with validation, error handling, and database
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Implement REST API endpoints with validation, error handling, and database
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | endpoint |
| description | Implement REST API endpoints with validation, error handling, and database |
| governance | Constitution ENG-004: Engineering Excellence & Software Craftsmanship Standard |
Implement REST API endpoints with validation, error handling, and database integration — turning an API specification into working, tested code.
An API specification describes what endpoints should do; this skill makes them real. It generates endpoint code with input validation, business logic, database operations, and standardized responses — production-ready from the start.
After API design (api-design) and schema design (db-schema) are complete.
When implementing any new endpoint or refactoring existing ones.
OpenAPI specification, database schema, authentication requirements.
Endpoint implementation (Node.js/Express example):
// src/routes/users.ts
import { Router, Request, Response } from "express";
import { z } from "zod";
import { db } from "../db";
import { hashPassword } from "../auth";
import { validate } from "../middleware/validate";
const router = Router();
// --- POST /api/v1/users ---
const createUserSchema = z.object({
name: z.string().min(1).max(100),
email: z.string().email(),
password: z.string().min(8),
});
router.post("/", validate(createUserSchema), async (req: Request, res: Response) => {
try {
const { name, email, password } = req.body;
// Check for duplicate email
const existing = await db.query(
"SELECT id FROM users WHERE email = $1",
[email]
);
if (existing.rows.length > 0) {
return res.status(409).json({
error: "Conflict",
message: "A user with this email already exists",
});
}
// Create user
const passwordHash = await hashPassword(password);
const result = await db.query(
`INSERT INTO users (name, email, password_hash)
VALUES ($1, $2, $3)
RETURNING id, name, email, role, created_at`,
[name, email, passwordHash]
);
return res.status(201).json({ data: result.rows[0] });
} catch (error) {
console.error("Error creating user:", error);
return res.status(500).json({
error: "Internal Server Error",
message: "An unexpected error occurred",
});
}
});
// --- GET /api/v1/users/:id ---
router.get("/:id", async (req: Request, res: Response) => {
try {
const { id } = req.params;
// Validate UUID format
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
if (!uuidRegex.test(id)) {
return res.status(400).json({
error: "Bad Request",
message: "Invalid user ID format",
});
}
const result = await db.query(
"SELECT id, name, email, role, created_at, updated_at FROM users WHERE id = $1",
[id]
);
if (result.rows.length === 0) {
return res.status(404).json({
error: "Not Found",
message: "User not found",
});
}
return res.json({ data: result.rows[0] });
} catch (error) {
console.error("Error fetching user:", error);
return res.status(500).json({
error: "Internal Server Error",
message: "An unexpected error occurred",
});
}
});
export default router;
{ error, message, details? }{ error: string, message: string, details?: any[] }Consult and write the ARAYA postoffice — the operational-directive channel. Advisory, never a gate: read it at cycle start, append your entry at cycle end, consider its directives, never be blocked by it. Governance acts never travel the postoffice.
Audit and enforce brand compliance across all projects and platforms — logo,
Design REST and GraphQL APIs following OpenAPI 3.1 standards. Produce complete
Connect frontend to backend — type-safe API clients, request/response handling,
Implement authentication and authorization middleware — JWT validation, role-based
Design scalable component architectures — design systems, component libraries,