I have successfully integrated the new lnpixels-app with the API backend and set up pnpm as the package manager. Here's what was accomplished:
- Accepts a specific set of pixels instead of requiring a rectangle
- Validates pixel coordinates, colors, and letters
- Calculates pricing using the backend pricing logic
- Supports up to 1000 pixels per request
- Returns a Lightning invoice for payment
- Modified the
lnpixels-appAPI client to use the new endpoint - Updated the save modal to send pixels to the new bulk endpoint
- Fixed WebSocket connections to use correct events (
pixel.update,activity.append) - Aligned pricing logic between frontend and backend
- Black pixels (
#000000) now cost 1 sat (like basic pixels) - Colored pixels cost 10 sats
- Letter pixels cost 100 sats
- Overwrite rule: 2x last sold price or base price, whichever is higher
- Added support for the new lnpixels-app port (3002)
- Updated both HTTP and WebSocket CORS settings
- Ensured proper cross-origin communication
- Created
pnpm-workspace.yamlconfiguration - Updated root
package.jsonwith convenient scripts - Added workspace scripts for running individual apps or all together
# Start API server (port 3000)
pnpm dev:api
# Start lnpixels-app (port 3002)
pnpm dev:app
# Or start both in parallel
pnpm dev:all- API: http://localhost:3000/api/
- New LNPixels App: http://localhost:3002/
- Old Web App: (can be started with
pnpm dev:web)
curl -X POST http://localhost:3000/api/invoices/pixels \
-H "Content-Type: application/json" \
-d @test-payload.jsonExpected response: Invoice with amount of 111 sats (100 + 10 + 1)
- Open http://localhost:3002/
- Draw some pixels on the canvas (try both paint and text modes)
- Click the save button to test the new bulk pixels endpoint
- Verify that the pricing is calculated correctly
api/src/routes.ts: Added new/invoices/pixelsendpointapi/src/pricing.ts: Updated pricing logic for black pixelsapi/src/server.ts: Added CORS middlewareapi/src/socket.ts: Updated CORS originsapi/test/invoices.test.ts: Added tests for new endpoint
lnpixels-app/lib/api.ts: AddedcreatePixelsInvoicemethodlnpixels-app/components/save-modal.tsx: Updated to use new endpointlnpixels-app/hooks/use-websocket.ts: Fixed WebSocket eventslnpixels-app/package.json: Updated dev script to use port 3002
pnpm-workspace.yaml: Created workspace configurationpackage.json: Updated with pnpm scripts and workspace management
- Flexible Pixel Selection: Users can now paint any shape/pattern and save it as a single purchase
- Better Performance: Single API call instead of multiple individual pixel purchases
- Consistent Pricing: Frontend and backend pricing logic are now aligned
- Modern Tooling: Using pnpm for better dependency management and monorepo support
- Real-time Updates: WebSocket integration for live pixel updates
The integration is complete and ready for testing! The new lnpixels-app provides a much better user experience while maintaining compatibility with the existing API and payment system.