cosmoye
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
index.ts
https://hails--a474c996335211f09dff9e149126039e.web.val.run
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 token
GET /api/products- Get all productsGET /api/products/:id- Get product detailsGET /api/products/categories- Get product categories
GET /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 cart
POST /api/orders- Create a new orderGET /api/orders- Get user's order historyGET /api/orders/:id- Get order details
POST /api/payment/process- Process paymentGET /api/payment/methods- Get available payment methods
- Framework: Hono (TypeScript)
- Database: SQLite
- Authentication: JWT
- Payment Processing: Stripe API integration
├── 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:
- Set up your Android app to make HTTP requests to the API endpoints
- Use the authentication endpoints to manage user sessions
- Implement the product browsing, cart management, and checkout flows
- Handle payment processing through the payment endpoints
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