This is a RESTful API backend service built on Val Town to support an Android e-commerce application. The API provides endpoints for product browsing, user authentication, cart management, payment processing, and order tracking.
POST /api/auth/register - Register a new userPOST /api/auth/login - Login and get authentication tokenGET /api/products - Get all productsGET /api/products/:id - Get product detailsGET /api/products/categories - Get product categoriesGET /api/cart - Get user's cartPOST /api/cart - Add item to cartPUT /api/cart/:itemId - Update cart item quantityDELETE /api/cart/:itemId - Remove item from cartPOST /api/orders - Create a new orderGET /api/orders - Get user's order historyGET /api/orders/:id - Get order detailsPOST /api/payment/process - Process paymentGET /api/payment/methods - Get available payment methods├── backend/
│ ├── database/
│ │ ├── migrations.ts # Schema definitions
│ │ └── queries.ts # DB query functions
│ ├── routes/ # Route modules
│ │ ├── auth.ts
│ │ ├── products.ts
│ │ ├── cart.ts
│ │ ├── orders.ts
│ │ └── payment.ts
│ ├── middleware/
│ │ └── auth.ts # Authentication middleware
│ ├── services/
│ │ └── payment.ts # Payment processing service
│ └── index.ts # Main entry point
└── shared/
└── types.ts # Shared type definitions
To use this API with your Android app:
The following environment variables need to be set in Val Town:
JWT_SECRET - Secret key for JWT token generationSTRIPE_SECRET_KEY - Stripe API secret key for payment processing