xiaohongshu
xiaohongshu
migrate-service-to-container
Guides migration from old_code/ to containers/ following SERVICE_MIGRATION_GUIDE.md. Transforms imports to use @coder/shared, adds tenantId to database queries, replaces hardcoded URLs with config, updates routes with auth/tenant enforcement, sets up event publishers/consumers, and transforms ser...
Full skill instructions
Guides migration from old_code/ to containers/ following SERVICE_MIGRATION_GUIDE.md and ModuleImplementationGuide.md standards.
Before migrating, analyze:
Use create-container-module skill or manually create:
mkdir -p containers/<service-name>/{config,src/{config,routes,services,types,utils,events,middleware},tests/{unit,integration}}
Old Pattern:
import { config } from '../config/env.js';
import { CosmosClient } from '@azure/cosmos';
New Pattern:
import { CosmosDBClient } from '@coder/shared';
import { loadConfig } from '../config';
Reference: ModuleImplementationGuide.md Section 5 (Dependency Rules)
Old Pattern:
async getData(id: string) {
const query = `SELECT * FROM c WHERE c.id = @id`;
// ❌ No tenantId
}
New Pattern:
async getData(tenantId: string, id: string) {
const container = this.db.getContainer('service_data');
const query = `SELECT * FROM c WHERE c.tenantId = @tenantId AND c.id = @id`;
const parameters = [
{ name: '@tenantId', value: tenantId },
{ name: '@id', value: id }
];
// ✅ tenantId required, uses shared client
}
Reference: SERVICE_MIGRATION_GUIDE.md Step 6, ModuleImplementationGuide.md Section 8
Old Pattern:
const response = await fetch('http://localhost:3021/api/users/123');
New Pattern:
import { ServiceClient } from '@coder/shared';
const client = new ServiceClient({
baseUrl: config.services.auth.url, // From config
timeout: 5000,
});
const response = await client.get('/api/v1/users/123', {
headers: {
'X-Tenant-ID': tenantId,
'Authorization': `Bearer ${serviceToken}`,
},
});
Reference: SERVICE_MIGRATION_GUIDE.md Step 7, ModuleImplementationGuide.md Section 5.3
Old Pattern:
fastify.get('/api/my-service/data', async (request, reply) => {
const service = new MyService();
const data = await service.getData(request.params.id);
return reply.send(data);
});
New Pattern:
import { authenticateRequest, tenantEnforcementMiddleware } from '@coder/shared';
fastify.get<{ Params: { id: string } }>(
'/api/v1/data/:id',
{
preHandler: [authenticateRequest(), tenantEnforcementMiddleware()],
},
async (request, reply) => {
// ✅ tenantId available from tenantEnforcementMiddleware
const tenantId = request.user!.tenantId;
const data = await service.getData(tenantId, request.params.id);
return reply.send({ data });
}
);
Reference: SERVICE_MIGRATION_GUIDE.md Step 5
Old Pattern:
throw new Error('Something went wrong');
New Pattern:
import { AppError } from '@coder/shared';
throw new AppError('Something went wrong', 400, 'BAD_REQUEST');
Reference: ModuleImplementationGuide.md Section 10 (Error Handling)
New Pattern:
import { EventPublisher } from '@coder/shared';
const publisher = new EventPublisher(config.rabbitmq);
await publisher.publish('service.resource.created', {
id: resource.id,
tenantId: tenantId,
timestamp: new Date().toISOString(),
});
Reference: ModuleImplementationGuide.md Section 9 (Event-Driven Communication)
Old Pattern:
const service = new MyService(cosmosClient, redis, monitoring);
New Pattern:
import { getDatabaseClient, getCacheClient } from '@coder/shared';
const db = getDatabaseClient();
const cache = getCacheClient();
const service = new MyService(db, cache);
xiaohongshu
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