Skip to content

Commit

Permalink
Merge pull request #5 from bleu/luiz/op-294-create-quest-endpoint
Browse files Browse the repository at this point in the history
feat: create mocked quest endpoint
  • Loading branch information
ribeirojose authored Oct 4, 2024
2 parents 4fdaa65 + fb8247a commit 66e3820
Show file tree
Hide file tree
Showing 22 changed files with 545 additions and 148 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,32 @@ jobs:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "20"

- name: Run install
uses: borales/actions-yarn@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
cmd: install
version: 9

- name: Build production bundle
uses: borales/actions-yarn@v4
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
cmd: build
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build production bundle
run: pnpm build

- name: Test the app
uses: borales/actions-yarn@v4
with:
cmd: test
run: pnpm test
2 changes: 1 addition & 1 deletion apps/govquests-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "bin/dev"
"dev": "cd rails_app && bin/dev"
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion apps/govquests-api/rails_app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ gem "thruster", require: false
# gem "image_processing", "~> 1.2"

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible
# gem "rack-cors"
gem "rack-cors"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
Expand Down
5 changes: 5 additions & 0 deletions apps/govquests-api/rails_app/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ GEM
raabro (1.4.0)
racc (1.8.1)
rack (3.1.7)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -368,7 +370,9 @@ GEM
sorbet (0.5.11463)
sorbet-static (= 0.5.11463)
sorbet-runtime (0.5.11463)
sorbet-static (0.5.11463-aarch64-linux)
sorbet-static (0.5.11463-universal-darwin)
sorbet-static (0.5.11463-x86_64-linux)
sorbet-static-and-runtime (0.5.11463)
sorbet (= 0.5.11463)
sorbet-runtime (= 0.5.11463)
Expand Down Expand Up @@ -457,6 +461,7 @@ DEPENDENCIES
pry-meta
pry-rails (~> 0.3.9)
puma (>= 5.0)
rack-cors
rails!
rails_event_store (~> 2.15.0)
rubocop
Expand Down
182 changes: 182 additions & 0 deletions apps/govquests-api/rails_app/app/controllers/quests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# app/controllers/quests_controller.rb
class QuestsController < ApplicationController
def index
quests = [
{
id: "1",
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
status: "start",
rewards: [
{
type: "Points",
amount: 50
},
{
type: "OP",
amount: 2
}
],
intro: "First things first: understand what are the Optimism Values and what is expect of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
},
{
content: "Optimistic Vision",
duration: 10,
},
{
content: "Working Constitution",
duration: 15,
},
{
content: "Delegate Expectations",
duration: 12,
},
]
},
{
id: "2",
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
status: "start",
rewards: [
{
type: "Points",
amount: 100
}
],
intro: "First things first: understand what are the Optimism Values and what is expect of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
},
{
content: "Optimistic Vision",
duration: 15,

},
{
content: "Working Constitution",
duration: 20,
},
{
content: "Delegate Expectations",
duration: 25,
},
]
},
{
id: "3",
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
status: "start",
rewards: [
{
type: "Points",
amount: 50
},
{
type: "OP",
amount: 2
}
],
intro: "First things first: understand what are the Optimism Values and what is expect of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
},
{
content: "Optimistic Vision",
duration: 10,

},
{
content: "Working Constitution",
duration: 15,
},
{
content: "Delegate Expectations",
duration: 12,
},
]
},
{
id: "4",
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
status: "start",
rewards: [
{
type: "Points",
amount: 100
}
],
intro: "First things first: understand what are the Optimism Values and what is expect of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
},
{
content: "Optimistic Vision",
duration: 15,

},
{
content: "Working Constitution",
duration: 20,
},
{
content: "Delegate Expectations",
duration: 25,
},
]
},
]

render json: quests
end
def show
quest = {
img_url: "https://file.coinexstatic.com/2023-11-16/BB3FDB00283C55B4C36B94CFAC0C3271.png",
title: "Governance 101",
status: "start",
rewards: [
{
type: "Points",
amount: 50
},
{
type: "OP",
amount: 2
}
],
intro: "First things first: understand what are the Optimism Values and what is expect of you in this important role.",
steps: [
{
content: "Code of Conduct",
duration: 15,
},
{
content: "Optimistic Vision",
duration: 10,
},
{
content: "Working Constitution",
duration: 15,
},
{
content: "Delegate Expectations",
duration: 12,
},
]
}

render json: quest
end
end
18 changes: 9 additions & 9 deletions apps/govquests-api/rails_app/config/initializers/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

# Read more: https://github.com/cyu/rack-cors

# Rails.application.config.middleware.insert_before 0, Rack::Cors do
# allow do
# origins "example.com"
#
# resource "*",
# headers: :any,
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
# end
# end
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "localhost:3000"

resource "*",
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
1 change: 1 addition & 0 deletions apps/govquests-api/rails_app/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

# Defines the root path route ("/")
# root "posts#index"
resources :quests
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class CreateQuests < ActiveRecord::Migration[8.0]
def change
create_table :quests do |t|
t.string :img_url
t.string :title
t.string :reward_type
t.text :intro
t.text :steps

t.timestamps
end
end
end
12 changes: 11 additions & 1 deletion apps/govquests-api/rails_app/db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/govquests-frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
1 change: 1 addition & 0 deletions apps/govquests-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"check-types": "tsc --noEmit"
},
"dependencies": {
"lucide-react": "^0.447.0",
"next": "14.2.13",
"react": "^18",
"react-dom": "^18"
Expand Down
Loading

0 comments on commit 66e3820

Please sign in to comment.