
Unlisted
Like
readback-api
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.
Viewing readonly version of main branch: v103View latest version
This module handles usage tracking for the speech synthesis API.
| Column | Type | Description |
|---|---|---|
| id | INTEGER PRIMARY KEY | Auto-incrementing unique identifier |
| customer_id | TEXT NOT NULL | Customer ID from RevenueCat |
| character_count | INTEGER NOT NULL | Number of characters in the request |
| request_timestamp | TEXT NOT NULL | ISO timestamp when request was made |
| created_at | TEXT DEFAULT CURRENT_TIMESTAMP | Database insertion timestamp |
Indexes:
customer_id- For efficient customer lookupsrequest_timestamp- For efficient date range queries
Creates the usage tracking table if it doesn't exist. Called automatically when the module is imported.
Records a usage event for a customer.
Returns the total character count used by a customer in the current calendar month.
Returns detailed usage history for a customer (useful for debugging or admin dashboards).
Monthly usage is calculated based on calendar months:
- Start: 1st day of the month at 00:00:00
- End: Last day of the month at 23:59:59.999
This means customers get a fresh allowance on the 1st of each month, regardless of when they subscribed.
- Indexes on
customer_idandrequest_timestampensure fast queries - Monthly usage queries use date range filtering for efficiency
- Table name includes version suffix (
_v1) for easy schema migrations