Skip to content

Commit

Permalink
Add first rest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhbhatia committed Dec 13, 2024
1 parent fbfab55 commit 1f5633a
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 75 deletions.
150 changes: 75 additions & 75 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,71 +18,71 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.1.5)
actionpack (= 7.1.5)
activesupport (= 7.1.5)
actioncable (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (7.1.5)
actionpack (= 7.1.5)
activejob (= 7.1.5)
activerecord (= 7.1.5)
activestorage (= 7.1.5)
activesupport (= 7.1.5)
actionmailbox (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.1.5)
actionpack (= 7.1.5)
actionview (= 7.1.5)
activejob (= 7.1.5)
activesupport (= 7.1.5)
actionmailer (7.1.5.1)
actionpack (= 7.1.5.1)
actionview (= 7.1.5.1)
activejob (= 7.1.5.1)
activesupport (= 7.1.5.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.2)
actionpack (7.1.5)
actionview (= 7.1.5)
activesupport (= 7.1.5)
actionpack (7.1.5.1)
actionview (= 7.1.5.1)
activesupport (= 7.1.5.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actiontext (7.1.5)
actionpack (= 7.1.5)
activerecord (= 7.1.5)
activestorage (= 7.1.5)
activesupport (= 7.1.5)
actiontext (7.1.5.1)
actionpack (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.1.5)
activesupport (= 7.1.5)
actionview (7.1.5.1)
activesupport (= 7.1.5.1)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (7.1.5)
activesupport (= 7.1.5)
activejob (7.1.5.1)
activesupport (= 7.1.5.1)
globalid (>= 0.3.6)
activemodel (7.1.5)
activesupport (= 7.1.5)
activerecord (7.1.5)
activemodel (= 7.1.5)
activesupport (= 7.1.5)
activemodel (7.1.5.1)
activesupport (= 7.1.5.1)
activerecord (7.1.5.1)
activemodel (= 7.1.5.1)
activesupport (= 7.1.5.1)
timeout (>= 0.4.0)
activestorage (7.1.5)
actionpack (= 7.1.5)
activejob (= 7.1.5)
activerecord (= 7.1.5)
activesupport (= 7.1.5)
activestorage (7.1.5.1)
actionpack (= 7.1.5.1)
activejob (= 7.1.5.1)
activerecord (= 7.1.5.1)
activesupport (= 7.1.5.1)
marcel (~> 1.0)
activesupport (7.1.5)
activesupport (7.1.5.1)
base64
benchmark (>= 0.3)
bigdecimal
Expand All @@ -104,7 +104,7 @@ GEM
activerecord (>= 5.2, < 8.2)
activesupport (>= 5.2, < 8.2)
aws-eventstream (1.3.0)
aws-partitions (1.1018.0)
aws-partitions (1.1023.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
Expand All @@ -113,7 +113,7 @@ GEM
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.176.0)
aws-sdk-s3 (1.176.1)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -159,9 +159,9 @@ GEM
devise (> 3.5.2, < 5)
rails (>= 4.2.0, < 7.3)
diff-lcs (1.5.1)
dotenv (3.1.4)
dotenv-rails (3.1.4)
dotenv (= 3.1.4)
dotenv (3.1.6)
dotenv-rails (3.1.6)
dotenv (= 3.1.6)
railties (>= 6.1)
drb (2.2.1)
erubi (1.13.0)
Expand Down Expand Up @@ -195,13 +195,13 @@ GEM
activesupport (>= 6.1)
graphiql-rails (1.10.1)
railties
graphql (2.3.20)
graphql (2.4.8)
base64
fiber-storage
graphql_devise (1.5.0)
graphql_devise (2.0.0)
devise_token_auth (>= 0.1.43, < 2.0)
graphql (>= 1.8, < 2.4)
rails (>= 4.2, < 7.2)
graphql (>= 1.8, < 2.5)
rails (>= 6.0, < 7.3)
zeitwerk
hashie (5.0.0)
honeybadger (5.26.0)
Expand All @@ -218,7 +218,7 @@ GEM
invisible_captcha (2.3.0)
rails (>= 5.2)
io-console (0.8.0)
irb (1.14.1)
irb (1.14.2)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.13.0)
Expand All @@ -229,7 +229,7 @@ GEM
railties (>= 6.0.0)
json (2.9.0)
language_server-protocol (3.17.0.3)
logger (1.6.2)
logger (1.6.3)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -255,7 +255,7 @@ GEM
monetize (~> 1.9)
money (~> 6.13)
railties (>= 3.0)
motor-admin (0.4.31)
motor-admin (0.4.32)
ar_lazy_preload (~> 1.0)
audited (~> 5.0)
cancancan (~> 3.0)
Expand All @@ -276,18 +276,18 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.4)
nokogiri (1.16.8-arm64-darwin)
nokogiri (1.17.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.8-x86_64-darwin)
nokogiri (1.17.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.8-x86_64-linux)
nokogiri (1.17.2-x86_64-linux)
racc (~> 1.4)
omniauth (2.1.2)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
orm_adapter (0.5.0)
pagy (9.3.2)
pagy (9.3.3)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -327,42 +327,42 @@ GEM
rack (>= 1.3)
rackup (2.2.1)
rack (>= 3)
rails (7.1.5)
actioncable (= 7.1.5)
actionmailbox (= 7.1.5)
actionmailer (= 7.1.5)
actionpack (= 7.1.5)
actiontext (= 7.1.5)
actionview (= 7.1.5)
activejob (= 7.1.5)
activemodel (= 7.1.5)
activerecord (= 7.1.5)
activestorage (= 7.1.5)
activesupport (= 7.1.5)
rails (7.1.5.1)
actioncable (= 7.1.5.1)
actionmailbox (= 7.1.5.1)
actionmailer (= 7.1.5.1)
actionpack (= 7.1.5.1)
actiontext (= 7.1.5.1)
actionview (= 7.1.5.1)
activejob (= 7.1.5.1)
activemodel (= 7.1.5.1)
activerecord (= 7.1.5.1)
activestorage (= 7.1.5.1)
activesupport (= 7.1.5.1)
bundler (>= 1.15.0)
railties (= 7.1.5)
railties (= 7.1.5.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.1)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.1.5)
actionpack (= 7.1.5)
activesupport (= 7.1.5)
railties (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rdoc (6.8.1)
rdoc (6.9.0)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
redis-client (0.23.0)
connection_pool
regexp_parser (2.9.3)
reline (0.5.12)
Expand All @@ -389,7 +389,7 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.2)
rubocop (1.69.1)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -399,7 +399,7 @@ GEM
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.36.2)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
rubocop-md (1.2.4)
rubocop (>= 1.45)
Expand All @@ -424,7 +424,7 @@ GEM
rubocop-packaging (~> 0.5)
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.0)
rubocop-rspec (3.2.0)
rubocop-rspec (3.3.0)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/api/v1/products_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

class Api::V1::ProductsController < ApplicationController
def new_releases
onboarded_products = Product.published.where(store: Store.where(user: User.where.not(stripe_user_id: nil)))
@new_releases = onboarded_products.order(created_at: :desc).take(12)
end
end
4 changes: 4 additions & 0 deletions app/views/api/v1/products/new_releases.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
json.array! @new_releases do |product|
json.product product
json.store product.store
end
7 changes: 7 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
post :results
end
end

namespace :api do
namespace :v1 do
get "new_releases", to: "products#new_releases", as: "new_releases"
end
end

resources :projects, param: :slug
resources :posts, param: :slug, only: [:index, :show]
resources :profiles, param: :slug, only: [:show, :index]
Expand Down

0 comments on commit 1f5633a

Please sign in to comment.