mirror of
https://github.com/zen-browser/rices.git
synced 2025-07-07 17:05:40 +02:00
- The rice database now includes new fields: - `version`: Represents the version of the rice entry. - `os`: Represents the operating system associated with the rice entry. - These fields are required for all new rice entries. refactor: Stop uploading rice.json to GitHub - The `rice.json` file is no longer uploaded to GitHub during rice creation or updates. - This reduces redundancy as all metadata is now managed directly in the database (Supabase). fix: Improve exception handling with proper HTTP status codes - Enhanced exception handling to align with standard HTTP status codes: - `BadRequestException` for validation errors. - `ConflictException` for duplicate entries. - `NotFoundException` for missing resources. - Generic `InternalServerErrorException` for unexpected errors. - This ensures the API returns meaningful and accurate responses. feat: Enhance rice download to act as a standard HTTP GET - The `findOne` method now returns the raw content of the rice file directly as the response body. - Removes unnecessary JSON wrappers, allowing the endpoint to behave like a typical HTTP GET request. - Improved usability for clients consuming the API.
26 lines
No EOL
1.1 KiB
PL/PgSQL
26 lines
No EOL
1.1 KiB
PL/PgSQL
--DROP TABLE IF EXISTS rices;
|
|
|
|
CREATE TABLE rices (
|
|
id UUID NOT NULL, -- Unique identifier
|
|
version VARCHAR(10) NOT NULL, -- Data version
|
|
os VARCHAR(30) NOT NULL, -- Operating system
|
|
slug VARCHAR(75) NOT NULL, -- Unique user-friendly identifier
|
|
name VARCHAR(75) NOT NULL, -- Name of the rice
|
|
token UUID NOT NULL, -- Unique authorization token
|
|
visits INTEGER DEFAULT 0 NOT NULL, -- Visit counter, initialized to 0
|
|
level INTEGER DEFAULT 0 NOT NULL, -- Level: 0 (Public), 1 (Verified)
|
|
created_at TIMESTAMP DEFAULT NOW(), -- Creation date
|
|
updated_at TIMESTAMP, -- Last update date
|
|
PRIMARY KEY (id, slug), -- Composite primary key
|
|
UNIQUE (slug), -- Ensure slug is unique
|
|
UNIQUE (name) -- Ensure name is unique
|
|
);
|
|
|
|
CREATE OR REPLACE FUNCTION increment_visits(slug_param TEXT)
|
|
RETURNS VOID AS $$
|
|
BEGIN
|
|
UPDATE rices
|
|
SET visits = visits + 1
|
|
WHERE slug = slug_param;
|
|
END;
|
|
$$ LANGUAGE plpgsql; |