BA
backend-setup
Express server scaffolding, plugin architecture, middleware patterns. Use when: starting backend development, adding middleware, troubleshooting server startup, designing plugin systems.
Install
mkdir -p .claude/skills/backend-setup && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15872" && unzip -o skill.zip -d .claude/skills/backend-setup && rm skill.zipInstalls to .claude/skills/backend-setup
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Express server scaffolding, plugin architecture, middleware patterns. Use when: starting backend development, adding middleware, troubleshooting server startup, designing plugin systems.186 chars✓ has a “when” trigger
About this skill
Backend Setup
When to Use
- Starting backend development
- Adding Express middleware
- Troubleshooting server startup
- Designing plugin architecture
- Initializing new activity modules
What This Skill Does
Scaffolds Express server with CampusOS plugin system, middleware templates, modular structure, and service initialization patterns.
Procedure
Phase 1: Project Structure
- Start in
/backend/src/ - Create directory structure:
src/ ├── index.js ├── app.js ├── server.js ├── plugin-loader.js ├── middleware/ │ ├── auth.js │ ├── error.js │ └── logger.js └── utils/ └── registry.js
Phase 2: Core Components
- Create
index.js- Express app initialization withexpress() - Create
app.js- Load middleware in correct order (auth → routes → error handling) - Create
server.js- HTTP server startup on configured PORT - Create
plugin-loader.js- Dynamic module discovery from/apps/
Phase 3: Middleware Implementation
- Authentication middleware - Verify JWT/tokens before route handlers
- Error handling middleware - Catch and format errors at end of chain
- Logging middleware - Track all requests/responses
- CORS configuration - Handle cross-origin requests
Phase 4: Plugin System
- Initialize module registry in
utils/registry.js - Scan
/apps/directory for modules withindex.js - Call
module.init(app, registry)for each module - Register routes via
app.post(),app.get()from each module - Mount services/authenticators/resolvers
Quick Reference
cd backend && pnpm install
npm run dev # Start dev server with hot reload
npm run build # Compile TypeScript (if used)
npm test # Run integration tests
# Set custom port: PORT=3001 npm run dev
Common Issues
| Issue | Solution |
|---|---|
| Plugin not loading | Check /apps/module/src/index.js exports init() function |
| Middleware order wrong | Place auth before routes, error handler at end of chain |
| Port in use | Change PORT env var or kill process: lsof -i :3000 |
| Routes undefined | Verify module calls app.post() during init phase |
| CORS errors | Configure CORS middleware with allowed origins |
| Services not registered | Ensure registry.set() called during module initialization |