extension-backend
Original:🇺🇸 English
Translated
Build backend APIs for Chrome extensions. NestJS + MongoDB (Mongoose) recommended stack. Auth, webhooks, license verification, CORS. Use when: backend, API, server, database, license, webhook.
10installs
Added on
NPX Install
npx skill4agent add quangpl/browser-extension-skills extension-backendTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Extension Backend
Build a secure, maintainable backend API for a Chrome extension. Recommended stack: NestJS + MongoDB (Mongoose).
When to Activate
Activate this skill when extension work requires:
- License verification / payment webhooks
- User authentication / account management
- Data sync across devices
- External API proxy (hide API keys from extension)
- Any server-side logic
Workflow (Execute This)
Step 1: Ask user to confirm requirements
- Do you need a backend? (explain why: API keys, auth, payments, sync)
- Stack preference: NestJS + MongoDB (recommended) or custom?
- Hosting target: Vercel / Railway / Fly.io / AWS / self-hosted?
- Features needed (pick from):
- User auth (Google OAuth via chrome.identity)
- License/subscription verification
- Payment webhooks (Stripe, Paddle, etc.)
- Data sync / storage API
- External API proxy
- Rate limiting
Step 2: Fetch framework docs
Use skill to fetch latest docs:
docs-seeker- NestJS: https://docs.nestjs.com/
- Mongoose: https://mongoosejs.com/docs/
- TypeScript style: https://google.github.io/styleguide/tsguide.html
- JavaScript style: https://google.github.io/styleguide/jsguide.html
Step 3: Scaffold the backend
bash
npx @nestjs/cli new extension-backend --strict --package-manager pnpm
cd extension-backend
pnpm add @nestjs/mongoose mongoose @nestjs/config class-validator class-transformer
pnpm add helmet @nestjs/throttler
pnpm add -D @types/expressStep 4: Project structure
src/
├── main.ts # Bootstrap, CORS, helmet, validation
├── app.module.ts # Root module
├── config/
│ └── configuration.ts # Env-based config
├── auth/
│ ├── auth.module.ts # Auth module
│ ├── auth.controller.ts # POST /auth/verify-token
│ ├── auth.service.ts # Token validation logic
│ └── guards/auth.guard.ts # Global auth guard
├── license/
│ ├── license.module.ts
│ ├── license.controller.ts # GET /license/verify
│ ├── license.service.ts # License CRUD
│ └── schemas/license.schema.ts # Mongoose schema
├── webhook/
│ ├── webhook.module.ts
│ ├── webhook.controller.ts # POST /webhook/stripe
│ └── webhook.service.ts # Process payment events
└── common/
├── filters/http-exception.filter.ts
├── interceptors/logging.interceptor.ts
└── dto/ # Shared DTOsStep 5: Essential endpoints
| Method | Endpoint | Purpose | Auth |
|---|---|---|---|
| POST | | Verify Google OAuth token | No |
| GET | | Check user subscription status | Yes |
| POST | | Receive payment events | Signature |
| GET | | Health check | No |
Step 6: Security checklist
See for implementation details.
references/security-patterns.md- Helmet middleware enabled
- CORS restricted to origin
chrome-extension://<ID> - Rate limiting (ThrottlerModule)
- Input validation (class-validator on all DTOs)
- Webhook signature verification
- No secrets in response bodies
- MongoDB injection prevention (Mongoose sanitizes by default)
- HTTPS only in production
References
- — Bootstrap, modules, CORS, env config
references/nestjs-setup.md - — Auth guard, rate limiting, webhook verification, CORS
references/security-patterns.md - — Schemas, services, queries, indexes
references/mongoose-patterns.md - — Endpoints the extension calls, token flow
references/extension-api-patterns.md
Related Skills
- — Payment gateway integration (calls this backend)
extension-payment - — Extension-side feature development
extension-dev - — Security audit for both extension and backend
extension-analyze