diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c56ed7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +config/database.yml +.idea/ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..d1be7cd --- /dev/null +++ b/Gemfile @@ -0,0 +1,16 @@ +source 'https://rubygems.org' + +gem 'sinatra' + +gem 'activerecord' +gem 'pg' +gem 'rake' +gem 'shrine', '~> 3.0' +gem 'sinatra-activerecord' +gem 'sinatra-contrib' + +group :development do + gem 'pry' + gem 'shotgun' + gem 'tux' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..3dfdf8a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,98 @@ +GEM + remote: https://rubygems.org/ + specs: + activemodel (6.0.2.2) + activesupport (= 6.0.2.2) + activerecord (6.0.2.2) + activemodel (= 6.0.2.2) + activesupport (= 6.0.2.2) + activesupport (6.0.2.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + zeitwerk (~> 2.2) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + backports (3.17.0) + bond (0.5.1) + coderay (1.1.2) + concurrent-ruby (1.1.6) + content_disposition (1.0.0) + down (5.1.1) + addressable (~> 2.5) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + method_source (1.0.0) + minitest (5.14.0) + multi_json (1.14.1) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pg (1.2.3) + pry (0.13.0) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (4.0.3) + rack (2.2.2) + rack-protection (2.0.8.1) + rack + rack-test (0.6.3) + rack (>= 1.0) + rake (13.0.1) + ripl (0.7.1) + bond (~> 0.5.1) + ripl-multi_line (0.3.1) + ripl (>= 0.3.6) + ripl-rack (0.2.1) + rack (>= 1.0) + rack-test (~> 0.6.2) + ripl (>= 0.7.0) + ruby2_keywords (0.0.2) + shotgun (0.9.2) + rack (>= 1.0) + shrine (3.2.1) + content_disposition (~> 1.0) + down (~> 5.1) + sinatra (2.0.8.1) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.8.1) + tilt (~> 2.0) + sinatra-activerecord (2.0.14) + activerecord (>= 3.2) + sinatra (>= 1.0) + sinatra-contrib (2.0.8.1) + backports (>= 2.8.2) + multi_json + mustermann (~> 1.0) + rack-protection (= 2.0.8.1) + sinatra (= 2.0.8.1) + tilt (~> 2.0) + thread_safe (0.3.6) + tilt (2.0.10) + tux (0.3.0) + ripl (>= 0.3.5) + ripl-multi_line (>= 0.2.4) + ripl-rack (>= 0.2.0) + sinatra (>= 1.2.1) + tzinfo (1.2.6) + thread_safe (~> 0.1) + zeitwerk (2.3.0) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord + pg + pry + rake + shotgun + shrine (~> 3.0) + sinatra + sinatra-activerecord + sinatra-contrib + tux + +BUNDLED WITH + 2.1.4 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..5cca1e3 --- /dev/null +++ b/Rakefile @@ -0,0 +1,2 @@ +require './config/environment' +require 'sinatra/activerecord/rake' diff --git a/api/images.rb b/api/images.rb new file mode 100644 index 0000000..e4178b6 --- /dev/null +++ b/api/images.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Application + class Api < Sinatra::Base + get '/' do + json images: [] + end + end +end diff --git a/application.rb b/application.rb new file mode 100644 index 0000000..bc1d509 --- /dev/null +++ b/application.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'sinatra/base' +require 'sinatra/json' + +module Application + class Api < Sinatra::Base + end +end + +Dir[File.dirname(__FILE__) + '/api/**'].sort.each do |route| + require route +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..5f2f26d --- /dev/null +++ b/config.ru @@ -0,0 +1,3 @@ +require './config/environment.rb' +require './application' +run Application::Api diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000..db365e9 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,2 @@ +ENV['APP_ENV'] ||= 'development' +Bundler.require(:default, ENV['APP_ENV']) diff --git a/db/migrate/20200327105306_create_photos.rb b/db/migrate/20200327105306_create_photos.rb new file mode 100644 index 0000000..24ed03c --- /dev/null +++ b/db/migrate/20200327105306_create_photos.rb @@ -0,0 +1,9 @@ +class CreatePhotos < ActiveRecord::Migration[6.0] + def change + create_table :photos do |t| + t.string :name + t.text :photo_data + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..7e49553 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,25 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `rails +# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2020_03_27_105306) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "photos", force: :cascade do |t| + t.string "name" + t.text "photo_data" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + +end diff --git a/models/photo.rb b/models/photo.rb new file mode 100644 index 0000000..88335de --- /dev/null +++ b/models/photo.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Photo < ActiveRecord::Base +end