spaps 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/local-server.js +16 -106
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spaps",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Sweet Potato Authentication & Payment Service CLI - Zero-config local development and project scaffolding",
5
5
  "main": "bin/spaps.js",
6
6
  "bin": {
@@ -523,6 +523,22 @@ class LocalServer {
523
523
  }
524
524
  });
525
525
 
526
+ // Mock usage endpoints
527
+ this.app.get('/api/usage/balance', (req, res) => {
528
+ res.json({
529
+ balance: 1000,
530
+ currency: 'credits',
531
+ updated_at: new Date().toISOString()
532
+ });
533
+ });
534
+
535
+ // Documentation endpoint
536
+ this.app.get('/docs', (req, res) => {
537
+ res.send(generateDocsHTML(this.port));
538
+ });
539
+ }
540
+
541
+ setupStripeRoutes() {
526
542
  // Enhanced Stripe Product Management - Full CRUD
527
543
 
528
544
  // GET /api/stripe/products - List all products with filtering
@@ -758,112 +774,6 @@ class LocalServer {
758
774
  }
759
775
  });
760
776
 
761
- // POST /api/stripe/prices - Create price for product
762
- this.app.post('/api/stripe/prices', async (req, res) => {
763
- try {
764
- const {
765
- product_id,
766
- unit_amount,
767
- currency = 'usd',
768
- recurring = null,
769
- nickname,
770
- metadata = {},
771
- active = true
772
- } = req.body;
773
-
774
- if (!product_id || !unit_amount) {
775
- return res.status(400).json({
776
- success: false,
777
- error: { message: 'Product ID and unit amount are required' }
778
- });
779
- }
780
-
781
- if (USE_REAL_STRIPE) {
782
- // Create price in Stripe
783
- const priceData = {
784
- product: product_id,
785
- unit_amount: parseInt(unit_amount),
786
- currency,
787
- metadata: {
788
- ...metadata,
789
- spaps_managed: 'true'
790
- }
791
- };
792
-
793
- if (recurring) {
794
- priceData.recurring = {
795
- interval: recurring.interval || 'month',
796
- interval_count: recurring.interval_count || 1
797
- };
798
- }
799
-
800
- if (nickname) priceData.nickname = nickname;
801
-
802
- const stripePrice = await stripe.prices.create(priceData);
803
-
804
- res.json({
805
- success: true,
806
- data: {
807
- price: {
808
- id: stripePrice.id,
809
- product: stripePrice.product,
810
- unit_amount: stripePrice.unit_amount,
811
- currency: stripePrice.currency,
812
- type: stripePrice.type,
813
- recurring: stripePrice.recurring,
814
- nickname: stripePrice.nickname,
815
- active: stripePrice.active,
816
- created: stripePrice.created
817
- }
818
- }
819
- });
820
- } else {
821
- // Mock price creation
822
- res.json({
823
- success: true,
824
- data: {
825
- price: {
826
- id: `price_local_${Date.now()}`,
827
- product: product_id,
828
- unit_amount,
829
- currency,
830
- type: recurring ? 'recurring' : 'one_time',
831
- recurring,
832
- nickname,
833
- active,
834
- created: Math.floor(Date.now() / 1000)
835
- }
836
- }
837
- });
838
- }
839
- } catch (error) {
840
- console.error('Create price error:', error);
841
- res.status(500).json({
842
- success: false,
843
- error: {
844
- code: 'CREATE_PRICE_ERROR',
845
- message: error.message || 'Failed to create price'
846
- }
847
- });
848
- }
849
- });
850
-
851
- // Mock usage endpoints
852
- this.app.get('/api/usage/balance', (req, res) => {
853
- res.json({
854
- balance: 1000,
855
- currency: 'credits',
856
- updated_at: new Date().toISOString()
857
- });
858
- });
859
-
860
- // Documentation endpoint
861
- this.app.get('/docs', (req, res) => {
862
- res.send(generateDocsHTML(this.port));
863
- });
864
- }
865
-
866
- setupStripeRoutes() {
867
777
  // Mock Stripe checkout session
868
778
  this.app.post('/api/stripe/create-checkout-session', async (req, res) => {
869
779
  const { price_id, success_url, cancel_url } = req.body;