Migrate subscription management endpoints to nexus service#126
Migrate subscription management endpoints to nexus service#126jeroenrinzema merged 15 commits intomainfrom
Conversation
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
…ilwind CSS Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
jeroenrinzema
left a comment
There was a problem hiding this comment.
Make generate and the linter are failing would you be able to take a look at this. Could you also include some CSRF configuration options in the project?
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Fixed in 9fa2bcf:
The configuration is ready for CSRF middleware implementation. All environment variables use the |
|
@copilot there are still some auto generated files out of date. Please run make generate to update all files |
All auto-generated files are already up to date. I ran
The only error from |
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
Co-authored-by: jeroenrinzema <3440116+jeroenrinzema@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR successfully migrates subscription management endpoints from the legacy Node.js platform service to the new Go-based nexus service, implementing both admin management APIs and user-facing subscription preference pages with server-side rendered HTML templates styled using Tailwind CSS.
Changes:
- Added complete subscription CRUD operations for project administrators via REST API
- Implemented user-facing subscription preference management with HTML templates
- Integrated Tailwind CSS v4.1.18 compilation into the build toolchain using pnpm
- Added CSRF configuration options (implementation deferred to future PR)
Reviewed changes
Copilot reviewed 22 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| services/nexus/internal/store/subscriptions.go | Added store methods for listing, creating, updating subscriptions and retrieving all user subscriptions |
| services/nexus/internal/http/http.go | Added comprehensive CSRF configuration structure with environment variable bindings |
| services/nexus/internal/http/controllers/v1/public/templates/*.html | Created server-side rendered HTML templates for preferences and unsubscribe pages |
| services/nexus/internal/http/controllers/v1/public/subscriptions.go | Implemented subscription controller with preference management and email unsubscribe handlers |
| services/nexus/internal/http/controllers/v1/public/static/* | Added Tailwind CSS configuration, input, and compiled output files |
| services/nexus/internal/http/controllers/v1/management/subscriptions.go | Implemented admin subscription management controller with CRUD operations |
| services/nexus/internal/http/controllers/v1/management/subscriptions_test.go | Added comprehensive test coverage for subscription endpoints |
| services/nexus/oapi/resources.yml | Defined OpenAPI specifications for both admin and public subscription endpoints |
| package.json | Added tailwindcss v4.1.18 as dev dependency |
| Makefile | Integrated Tailwind CSS binary installation and pnpm install into generate target |
| go.mod | Moved clerk and svix dependencies from indirect to direct |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Subscription Endpoints Migration Complete ✅
Successfully migrated subscription management endpoints from the legacy platform service (Node.js/TypeScript) to the new nexus service (Go).
Latest Changes
Integrated Tailwind CSS into toolchain:
generate.goin static directory with directive to compile CSS viapnpm exec tailwindcssgeneratetarget to runpnpm installbefore go generate, ensuring tailwindcss is availablemake generateworkflow using pnpm instead of standalone binaryImplemented unsubscribe and reorganized CSS:
Full unsubscribe logic - EmailUnsubscribe now:
Reorganized Tailwind CSS structure:
tailwind.config.jstostatic/directory (subscription-specific)output.csstostyles.css(better name)static/styles.cssinstead ofstatic/css/output.css/static/styles.css../templates/**/*.htmlLinter fix - Converted struct literal to type conversion in
GetAllUserSubscriptions()(gosimple S1016)CSRF configuration - Added comprehensive CSRF protection configuration options to
http.Config:CSRF_ENABLED- Enable/disable CSRF protection (default: true)CSRF_SECRET- Secret key for token generationCSRF_TOKEN_LENGTH- Token length in bytes (default: 32)CSRF_COOKIE_NAME- Cookie name (default: "csrf_token")CSRF_HEADER_NAME- Header name (default: "X-CSRF-Token")CSRF_FIELD_NAME- Form field name (default: "csrf_token")CSRF_COOKIE_SECURE- HTTPS only (default: true)CSRF_COOKIE_HTTP_ONLY- HTTP only (default: true)CSRF_COOKIE_SAME_SITE- SameSite attribute (default: "strict")CSRF_TRUSTED_ORIGINS- List of trusted originsImplementation
Management API (Admin)
GET /api/admin/projects/{projectID}/subscriptions- List subscription typesPOST /api/admin/projects/{projectID}/subscriptions- Create subscription typeGET /api/admin/projects/{projectID}/subscriptions/{subscriptionID}- Get subscriptionPATCH /api/admin/projects/{projectID}/subscriptions/{subscriptionID}- Update subscriptionPublic API (User-Facing)
GET /preferences/{projectID}/{userID}- User subscription preferences pagePOST /preferences/{projectID}/{userID}- Update user preferencesGET /unsubscribe/email- Email unsubscribe with full implementation ✅GET /static/styles.css- Compiled Tailwind CSSStore Layer
ListSubscriptions()- Paginated listing with limit/offsetGetAllUserSubscriptions()- Get all subscriptions without paginationUpdateSubscription()- Update subscription name and visibilityToggleSubscription()- Used for unsubscribe functionalityTechnical Details
make generateusing pnpmstatic/directory with config, embedded via go:embedFile Structure
Build Workflow
make generate ↓ pnpm install (installs tailwindcss) ↓ go generate ./... (processes all go:generate directives) ↓ static/generate.go: pnpm exec tailwindcss ... (compiles CSS) ↓ styles.css updatedCSRF Configuration
The CSRF configuration options are now available and can be set via environment variables. The actual CSRF middleware implementation should be added in a future PR to utilize these configuration options.
Example environment variables:
CSS Build Process
The Tailwind CSS is automatically compiled when running:
For manual rebuilding:
Known Limitations
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.