xiaohongshu
xiaohongshu
integrate-routes
Mount routes in app.ts with dependency injection. Use after creating routes to wire them into the application. Triggers on "mount routes", "add to app", "wire routes", "integrate routes".
Full skill instructions
Mounts newly created routes into src/app.ts with proper dependency injection chain.
File to modify: src/app.ts
When to use: After creating routes with create-routes skill
Before integrating routes, ensure you have:
src/schemas/{entity}.schema.ts)src/repositories/mockdb/{entity}.mockdb.repository.ts)src/services/{entity}.service.ts)src/controllers/{entity}.controller.ts)src/routes/{entity}.router.ts)Add imports at the top of src/app.ts:
// Route factory
import { create{Entity}Routes } from "@/routes/{entity-name}.router";
// Controller
import { {Entity}Controller } from "@/controllers/{entity-name}.controller";
// Service
import { {Entity}Service } from "@/services/{entity-name}.service";
// Repository (choose one based on environment)
import { MockDb{Entity}Repository } from "@/repositories/mockdb/{entity-name}.mockdb.repository";
// OR for production:
// import { MongoDb{Entity}Repository } from "@/repositories/mongodb/{entity-name}.mongodb.repository";
Add the dependency instantiation in the appropriate section of app.ts:
// =============================================================================
// {Entity} Resource Dependencies
// =============================================================================
const {entity}Repository = new MockDb{Entity}Repository();
// OR for production: const {entity}Repository = new MongoDb{Entity}Repository();
const {entity}Service = new {Entity}Service({entity}Repository);
const {entity}Controller = new {Entity}Controller({entity}Service);
Add the route mounting after other routes:
// =============================================================================
// Routes
// =============================================================================
// ... existing routes ...
// {Entity} routes
app.route("/{entities}", create{Entity}Routes({ {entity}Controller }));
Ensure the following order in app.ts:
const app = new Hono<AppEnv>())app.onError(globalErrorHandler))Always create dependencies in this order:
// 1. Repository (lowest level)
const repository = new MockDbEntityRepository();
// 2. Service (depends on repository)
const service = new EntityService(repository);
// 3. Controller (depends on service)
const controller = new EntityController(service);
// 4. Routes (depends on controller)
app.route("/entities", createEntityRoutes({ entityController: controller }));
/notes, /users, /projects/course-registrationsFor production-ready code, use environment-based selection:
import { env } from "@/env";
import { MockDbNoteRepository } from "@/repositories/mockdb/note.mockdb.repository";
import { MongoDbNoteRepository } from "@/repositories/mongodb/note.mongodb.repository";
const noteRepository =
env.NODE_ENV === "production"
? new MongoDbNoteRepository()
: new MockDbNoteRepository();
Group related dependencies with comments:
// =============================================================================
// Note Resource
// =============================================================================
const noteRepository = new MockDbNoteRepository();
const noteService = new NoteService(noteRepository);
const noteController = new NoteController(noteService);
// =============================================================================
// Project Resource
// =============================================================================
const projectRepository = new MockDbProjectRepository();
const projectService = new ProjectService(projectRepository);
const projectController = new ProjectController(projectService);
import { Hono } from "hono";
import { cors } from "hono/cors";
import type { AppEnv } from "@/schemas/app-env.schema";
import { globalErrorHandler } from "@/errors";
// Route factories
import { createNoteRoutes } from "@/routes/note.router";
import { createProjectRoutes } from "@/routes/project.router";
import { createEventsRoutes } from "@/routes/events.router";
// Controllers
import { NoteController } from "@/controllers/note.controller";
import { ProjectController } from "@/controllers/project.controller";
// Services
import { NoteService } from "@/services/note.service";
import { ProjectService } from "@/services/project.service";
// Repositories
import { MockDbNoteRepository } from "@/repositories/mockdb/note.mockdb.repository";
import { MockDbProjectRepository } from "@/repositories/mockdb/project.mockdb.repository";
// =============================================================================
// App Setup
// =============================================================================
const app = new Hono<AppEnv>();
// Global middleware
app.use("*", cors());
// =============================================================================
// Note Resource
// =============================================================================
const noteRepository = new MockDbNoteRepository();
const noteService = new NoteService(noteRepository);
const noteController = new NoteController(noteService);
// =============================================================================
// Project Resource
// =============================================================================
const projectRepository = new MockDbProjectRepository();
const projectService = new ProjectService(projectRepository);
const projectController = new ProjectController(projectService);
// =============================================================================
// Routes
// =============================================================================
app.route("/notes", createNoteRoutes({ noteController }));
app.route("/projects", createProjectRoutes({ projectController }));
app.route("/", createEventsRoutes());
// =============================================================================
// Error Handler
// =============================================================================
app.onError(globalErrorHandler);
export { app };
import type) where possibleapp.onError()require() - use ES modulescreate-routes - Creating the route factorycreate-controller - Creating the controllercreate-resource-service - Creating the servicecreate-resource - Complete resource workflowxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience