summaryrefslogtreecommitdiff
path: root/bin/api
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-03-17 16:48:25 -0600
committermo khan <mo@mokhan.ca>2025-03-17 16:48:25 -0600
commit338ff46e4ab799a4b159f8c2a79b73751f920727 (patch)
tree48924f09c5a65c3e2238882c87e6d195e4ff0adb /bin/api
parent084ec28adef9f16a0f38f0457662e9695dfcff8a (diff)
feat: fix the csv data and serve it from the REST API
Diffstat (limited to 'bin/api')
-rwxr-xr-xbin/api5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/api b/bin/api
index e63c713..83c2726 100755
--- a/bin/api
+++ b/bin/api
@@ -5,6 +5,7 @@ require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
+ gem "csv", "~> 3.0"
gem "declarative_policy", "~> 1.0"
gem "erb", "~> 4.0"
gem "globalid", "~> 1.0"
@@ -30,7 +31,9 @@ $host = ENV.fetch("HOST", "localhost:#{$port}")
class Entity
class << self
def all
- @items ||= []
+ @items ||= ::CSV.read(File.join(__dir__, "../db/#{self.name.downcase}s.csv"), headers: true).map do |row|
+ new(row.to_h.transform_keys(&:to_sym))
+ end
end
def create!(attributes)