Giter Club home page Giter Club logo

napa's Introduction

napa-v2-01-cropped-resized

Circle CI Dependency Status Code Climate Test Coverage

Napa is a simple framework for building Rack based APIs using Grape, Roar and ActiveRecord. It's designed to make it easy to quickly create and deploy new API services by providing generators, middlewares and a console similar to what you would expect from a Rails app.

Installation

Napa is available as a gem, to install it run:

gem install napa

Or, if you're using Bundler, add it to your Gemfile:

gem 'napa'

And run:

$ bundle install

Getting Started

See the Quickstart Guide for an intro to creating a simple service with Napa.

Usage

Run napa terminal prompt to see available features:

Commands:
  napa console [ENVIRONMENT]  # Start the Napa console
  napa deploy [TARGET]        # Deploys A Service to a given target (i.e. production, staging, etc.)
  napa generate [COMMAND]     # Generate new code
  napa help [COMMAND]         # Describe available commands or one specific command
  napa new <NAME> [PATH]      # Create a new Napa application
  napa server                 # Start the Napa server
  napa version                # Shows the Napa version number

Console

Similar to the Rails console, load an IRB session with your applications environment by running:

napa console

Deploy

Napa provides a CLI for deploying to a given environment by setting a git tag. This is useful for chef-based deploys where deploys are trigged when a git SHA changes.

napa deploy production
Are you sure you want to deploy this service? Y
#=> <git SHA> tagged as production by danielmackey at October 09, 2014 14:41

If you want to skip the 'Are you sure?' prompt, pass the --confirm flag to set the tag automatically

napa deploy production --confirm
#=> <git SHA> tagged as production by danielmackey at October 09, 2014 14:41

Rake Tasks

rake -T will give you a list of all available rake tasks:

rake db:create          # Create the database
rake db:drop            # Delete the database
rake db:migrate         # Migrate the database through scripts in db/migrate
rake db:reset           # Create the test database
rake db:schema:dump     # Create a db/schema.rb file that can be portably used against any DB supported by AR
rake db:schema:load     # Load a schema.rb file into the database
rake db:seed            # Load the seed data from db/seeds.rb
rake git:set_tag[tag]   # Set tag, which triggers deploy
rake git:verify         # Verify git repository is in a good state for deployment
rake routes             # display all routes for Grape

Middlewares

Napa includes a number of Rack middlewares that can be enabled to add functionality to your project.

Authentication

The Authentication middleware will add a simple header based authentication layer to all requests. This is just looking for a header of 'Passwords' = 'Your Password'. The passwords are defined in the .env file. You can allow multiple passwords by supplying a comma separated list. For example:

ALLOWED_HEADER_PASSWORDS='password1,password2'

If your application doesn't require authentication, you can simply remove the middleware.

Health Check

The Health Check middleware will add an endpoint at /health that will return some data about your app. This was created to allow monitoring tools a standardized way to monitor multiple services. This endpoint will return a response similar to this:

{
    "name": "service-name",
    "hostname": "host-name",
    "revision": "current-git-sha-of-app",
    "pid": 1234,
    "parent_pid": 1233,
    "napa_revision": "running-version-of-napa"
}

Logger

The Logger module is used to create a common log format across applications. The Logger is enable via a rack middleware by adding the line below to your config.ru file:

use Napa::Middleware::Logger

You can also enable the logger for ActiveRecord by adding the following line to an initializer:

ActiveRecord::Base.logger = Napa::Logger.logger

Napa::Logger.logger returns a Singleton instance of the Logging object, so it can be passed to other libraries or called directly. For example:

Napa::Logger.logger.debug 'Some Debug Message'

Scrubbing Logs of Sensitive Data

Some requests may contain sensitive information, such as passwords or credit card numbers. In order to protect this information, they should be filtered out from logs.

To do so, add the following line to an initializer:

Napa::ParamSanitizer.filter_params = [:password, :password_confirmation, :cvv, :card_number]

Note that the keys in the array above are just examples. They should be replaced with the parameters that have sensitive data in their value.

Example unfiltered request ( ... denotes other information):

{ ... "message":{"request":{"method":"POST","path":"/example","query":"name=Test%20User%200039\u0026password=password", ... "params":{"name":"Test User 0039","password":"password"} ...}}}

Example filtered request ( ... denotes other information):

{ ... "message":{"request":{"method":"POST","path":"/example","query":"name=Test%20User%200039\u0026password=[FILTERED]", ... "params":{"name":"Test User 0039","password":"[FILTERED]"} ...}}}

StatsD

There are two middlewares available to enable StatsD reporting, RequestStats and DatabaseStats. They can be enabled independently in your config.ru file:

use Napa::Middleware::RequestStats
use Napa::Middleware::DatabaseStats

RequestStats will emit information about your application's request count and response time.

DatabaseStats will emit information from ActiveRecord about query times.

Configuration

To configure StatsD in your application you will need to supply the STATSD_HOST and STATSD_PORT in your environment. Optionally, if your StatsD host requires an api token (i.e. hostedgraphite), you can configure that with the STATSD_API_KEY environment variable.

Logging

If you want to see the StatsD reporting in action you can hook up the logger to the Napa logger to see the requests in your logs.

Statsd.logger = Napa::Logger.logger

Caching

Napa adds a simple wrapper around ActiveSupport::Cache that allows you to easily access it similar to how it works in Rails. Napa.cache will give you access to all of the methods available in ActiveSupport::Cache::Store http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html. So, for example:

Napa.cache.read
Napa.cache.write
Napa.cache.fetch
...

By default it will use :memory_store, but you can override it to use any other caching strategy, like Memcache by setting the store:

Napa.cache = :dalli_store

Sorting

Napa has an optional module you can include in any Api called Napa::SortableApi. To include this, add include SortableApi in the helpers block of the Api.

SortableApi takes in a parameter for sort in the format of field1,field2,-field3, where field1 and field2 are used to sort ascending, and field3 is sorted descending. For example, -field4,field1 would be equivalent to `ORDER BY field4 DESC, field1'.

Call sorted_from_params(ar_relation, params[:sort]) passing in an ActiveRecord::Relation for ar_relation, and a comma-delimited string of field names for params[:sort].

Bugs & Feature Requests

Please add an issue in Github if you discover a bug or have a feature request.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

napa's People

Contributors

adrianpvds-mfon avatar ashtonthomas avatar benkimpel avatar brandonweiss avatar ckampfe avatar cpursley avatar craigulliott avatar darbyfrey avatar davidcelis avatar heymackey avatar hstrowd avatar ianneub avatar jdoconnor avatar joedivita avatar jonhoman avatar joshcheek avatar kevinreedy avatar kylecrum avatar leeacto avatar pcmantz avatar ryanjsims avatar seanhussey avatar shaqq avatar shayhowe avatar umtrey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

napa's Issues

Roar and Honeybadger updated, breaking default scaffold setup

The Gemfile contains just roar and honeybadger packages, both of which updated with breaking changes recently. When doing a rake db:reset command, for example, the output is

rake aborted!
LoadError: cannot load such file -- roar/representer/json

with a stacktrace behind it. Rolling only roar back then causes Rake to have a similar issue with honeybadger.

Setting roar to '~> 0.12.0' and honeybadger to '~> 1.16.7' seems to fix the problem.

Enhanced Health Endpoint

Current /health payload:

{"name":"service-name","hostname":"madeuphost.com","revision":"1327d39f220e1a177b7df1aeb62455e351c2a95c","pid":1234,"parent_pid":1235,"platform_revision":"0.1.2"}

Ideally, Napa would produce a health check at /health.json rather than /health (conforming to HTTP standards) with a modified payload:

{
"name": "service-name",
"hostname": "hostname",
"revision": "asdfasdfasdf",
"platform: {
"version": "0.1.2",
"name": "napa"
},
...

roar representer errors on startup

may be related with roar's 1.0.0 release changing where files are stored

Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.42
Using activesupport 4.0.13
Using builder 3.1.4
Using activemodel 4.0.13
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.13
Using addressable 2.3.6
Using ast 2.0.0
Using parser 2.2.0.2
Using astrolabe 1.3.0
Using descendants_tracker 0.0.4
Using ice_nine 0.11.1
Using axiom-types 0.1.1
Using coderay 1.1.0
Using coercible 1.0.0
Using safe_yaml 1.0.4
Using crack 0.4.2
Using database_cleaner 1.4.0
Using diff-lcs 1.2.5
Using docile 1.1.5
Using dotenv 1.0.2
Using equalizer 0.0.9
Using factory_girl 4.5.0
Using multipart-post 2.0.0
Using faraday 0.9.1
Using git 1.2.9.1
Using hashie 3.3.2
Using multi_xml 0.5.5
Using rack 1.6.0
Using rack-accept 0.4.5
Using rack-mount 0.8.3
Using virtus 1.0.4
Using grape 0.10.1
Using grape-entity 0.4.4
Using grape-swagger 0.9.0
Using json 1.8.2
Installing honeybadger 1.16.7
Using little-plugger 1.1.3
Using logging 1.8.2
Using method_source 0.8.2
Using mini_portile 0.6.2
Using mysql2 0.3.17
Using sawyer 0.6.0
Using octokit 3.7.0
Using rack-test 0.6.3
Using racksh 1.0.0
Using nokogiri 1.6.5
Using uber 0.0.13
Using representable 2.1.3
Using roar 1.0.0
Using statsd-ruby 1.2.1
Using thor 0.19.1
Using napa 0.4.0
Using powerpack 0.0.9
Using slop 3.6.0
Using pry 0.10.1
Using rack-cors 0.3.1
Using rainbow 2.0.0
Using rspec-support 3.1.2
Using rspec-core 3.1.7
Using rspec-expectations 3.1.2
Using rspec-mocks 3.1.3
Using rspec 3.1.0
Using ruby-progressbar 1.7.1
Using rubocop 0.28.0
Using shotgun 0.9
Using simplecov-html 0.8.0
Using simplecov 0.9.1
Using webmock 1.20.4
Using bundler 1.7.12
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
/t/testbar ❯❯❯ b napa c
/Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/napa-0.4.0/lib/napa/output_formatters/representer.rb:2:in `require': cannot load such file -- roar/representer/json (LoadError)
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/napa-0.4.0/lib/napa/output_formatters/representer.rb:2:in `<top (required)>'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/napa-0.4.0/lib/napa.rb:27:in `require'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/napa-0.4.0/lib/napa.rb:27:in `<top (required)>'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:76:in `require'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:72:in `each'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:61:in `each'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler/runtime.rb:61:in `require'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.7.12/lib/bundler.rb:134:in `require'
    from /private/tmp/testbar/app.rb:5:in `<top (required)>'
    from config.ru:1:in `require'
    from config.ru:1:in `block in <main>'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in `initialize'
    from config.ru:in `new'
    from config.ru:in `<main>'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:in `eval'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:40:in `parse_file'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/racksh-1.0.0/lib/racksh/init.rb:23:in `init'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/napa-0.4.0/lib/napa/cli.rb:60:in `console'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/joconnor/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/napa-0.4.0/bin/napa:5:in `<top (required)>'
    from /Users/joconnor/.rbenv/versions/2.1.5/bin/napa:23:in `load'
    from /Users/joconnor/.rbenv/versions/2.1.5/bin/napa:23:in `<main>'

Move database migration generator to Thor

Right now the db.rake file has a task to generate a database migration. We should move this into the generators so Thor can manage it, so that instead of calling:

rake db:generate:migration ...

We can call:

napa generate migration ...

concept of HEADER_PASSWORD should be optional - and off by default

It's frustrating if you cant write the hello world of services without understanding the password concept.

Even when you put

HEADER_PASSWORD=

in your .env file you still get an error.

I'd suggest we have HEADER_PASSWORD= as a default in the .env file and that means no password is required. That'll act as a good reminder for people to set one, and learn how it works. A comment in that file to documentation online would be good too.,

Building Gem complains about Gemspec dependencies

> gem build napa.gemspec
WARNING:  licenses is empty, but is recommended.  Use a license abbreviation from:
http://opensource.org/licenses/alphabetical
WARNING:  no homepage specified
WARNING:  description and summary are identical
WARNING:  open-ended dependency on rake (>= 0) is not recommended
  if rake is semantically versioned, use:
    add_runtime_dependency 'rake', '~> 0'
WARNING:  open-ended dependency on logging (>= 0) is not recommended
  if logging is semantically versioned, use:
    add_runtime_dependency 'logging', '~> 0'
WARNING:  open-ended dependency on dotenv (>= 0) is not recommended
  if dotenv is semantically versioned, use:
    add_runtime_dependency 'dotenv', '~> 0'
WARNING:  open-ended dependency on octokit (>= 0) is not recommended
  if octokit is semantically versioned, use:
    add_runtime_dependency 'octokit', '~> 0'
WARNING:  open-ended dependency on thor (>= 0) is not recommended
  if thor is semantically versioned, use:
    add_runtime_dependency 'thor', '~> 0'
WARNING:  open-ended dependency on virtus (>= 0) is not recommended
  if virtus is semantically versioned, use:
    add_runtime_dependency 'virtus', '~> 0'
WARNING:  open-ended dependency on grape (>= 0) is not recommended
  if grape is semantically versioned, use:
    add_runtime_dependency 'grape', '~> 0'
WARNING:  open-ended dependency on grape-swagger (>= 0) is not recommended
  if grape-swagger is semantically versioned, use:
    add_runtime_dependency 'grape-swagger', '~> 0'
WARNING:  open-ended dependency on roar (>= 0) is not recommended
  if roar is semantically versioned, use:
    add_runtime_dependency 'roar', '~> 0'
WARNING:  open-ended dependency on statsd-ruby (>= 0) is not recommended
  if statsd-ruby is semantically versioned, use:
    add_runtime_dependency 'statsd-ruby', '~> 0'
WARNING:  open-ended dependency on racksh (>= 0) is not recommended
  if racksh is semantically versioned, use:
    add_runtime_dependency 'racksh', '~> 0'
WARNING:  open-ended dependency on rspec (>= 0, development) is not recommended
  if rspec is semantically versioned, use:
    add_development_dependency 'rspec', '~> 0'
WARNING:  open-ended dependency on pry (>= 0, development) is not recommended
  if pry is semantically versioned, use:
    add_development_dependency 'pry', '~> 0'
WARNING:  open-ended dependency on git (>= 0, development) is not recommended
  if git is semantically versioned, use:
    add_development_dependency 'git', '~> 0'
WARNING:  open-ended dependency on rubocop (>= 0, development) is not recommended
  if rubocop is semantically versioned, use:
    add_development_dependency 'rubocop', '~> 0'
WARNING:  pessimistic dependency on activerecord (~> 3.2.2, development) may be overly strict
  if activerecord is semantically versioned, use:
    add_development_dependency 'activerecord', '~> 3.2', '>= 3.2.2'
WARNING:  open-ended dependency on sqlite3 (>= 0, development) is not recommended
  if sqlite3 is semantically versioned, use:
    add_development_dependency 'sqlite3', '~> 0'
WARNING:  See http://guides.rubygems.org/specification-reference/ for help
  Successfully built RubyGem
  Name: napa

Unable to run rake db:drop with remote Oracle

I receive this error when attempting db:drop. I'm assuming the db connection information isn't being fetched completely. db:migrate work fine, however.

$ bundle exec rake db:drop --trace
[DEPRECATION] This gem has been renamed to hashie-forbidden_attributes and will no longer be supported. Please switch to hashie-forbidden_attributes as soon as possible.
** Invoke db:drop (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:drop
rake aborted!
OCIError: ORA-12162: TNS:net service name is incorrectly specified
oci8.c:656:in oci8lib_210.so
/usr/lib/ruby/gems/2.1.0/gems/ruby-oci8-2.1.8/lib/oci8/oci8.rb:148:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:330:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:330:in `new_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:389:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:26:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:26:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_connection.rb:9:in `create'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-oracle_enhanced-adapter-1.5.6/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:152:in `oracle_enhanced_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.0.13/lib/active_record/connection_handling.rb:53:in `connection'
/home/vagrant/.bundler/ruby/2.1.0/napa-edb30c0d95c0/lib/tasks/db.rake:53:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:150:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => db:drop

JSON ErrorFormatter bug

The patched Grape ErrorFormatter::Json module will crash if options[:rescue_options][:backtrace] is true. It will attempt to merge the Napa::JsonError object which isn't a hash. I'm not sure if a more elegant solution is order but a quick fix is simply converting it to a hash before merging.

Port db rake tasks from Rails

@bellycard/platform @darbyfrey

so far, the current database rake tasks we have get us by pretty far:

https://github.com/bellycard/napa/blob/master/lib/tasks/db.rake

but there are other niceties in ActiveRecord that we're not leveraging (such as migrating up/down a version):

https://github.com/rails/rails/blob/e46202139647b458b8c3d5eb3a0dff29474159d3/activerecord/lib/active_record/railties/databases.rake

I'm not quite sure loading the databases.rake file would be a quick and dirty solution because there's still some Rails-specific stuff there.

There also might be other rake tasks that we could use.

Docs mention db:test:prepare but it does not work

Nor does db:rest correctly affect the test db

This affects the development database rather than test:

RACK_ENV=test rake db:reset

This doesn't work at all (and I see no reference to the prepare task in db.rake)

RACK_ENV=test rake db:test:prepare

Some clues as to where to pursue this would be helpful

0.4.0 Milestone

@bellycard/platform

By using the Milestone feature on Github, we can have a tangible way to say "this is where Napa is stable," as well as having a structure around a 0.4.0 release.

My guess is most of it will be writing specs around our latest features. We can push out minor releases if we discover bugs after the fact.

Could be a solid hacktime for 2 or 3 of us. Thoughts?

Cannot run napa console (Napa v0.3.0)

Not sure if this is a bug but i'm getting this on two of my servers when trying to run napa console.

 $ napa console
WARN: Unresolved specs during Gem::Specification.reset:
      rake (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- readline (LoadError)
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/irb/completion.rb:9:in `<top (required)>'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/napa-0.3.0/lib/napa/cli.rb:43:in `rescue in console'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/napa-0.3.0/lib/napa/cli.rb:38:in `console'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /home/deploy/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/napa-0.3.0/bin/napa:5:in `<top (required)>'
    from /home/deploy/.rbenv/versions/2.1.2/bin/napa:23:in `load'
    from /home/deploy/.rbenv/versions/2.1.2/bin/napa:23:in `<main>'
FAIL

I tried gem cleanup rake but it didn't work.

Also I tried updating the napa gem on an existing project and that just made my api no longer work (but that may be a separate issue) so I'm stuck with napa v0.3.0 for now.

Thanks!

napa g migration ambiguous matches

Running napa g api or napa g migration gives this response:

napa g api ...
Ambiguous command g matches [generate, generate api, generate readme]

ActiveRecord Migration Generators

In rails, you can do something like

rails generate migration AddPartNumberToProducts part_number:string:index

which would generate

class AddPartNumberToProducts < ActiveRecord::Migration
  def change
    add_column :products, :part_number, :string
    add_index :products, :part_number
  end
end

with the naming scheme YYYYMMDDHHMMSS_add_part_number_to_products.rb

It looks like the migration generators for Napa are here:

migration_generator.rb

Is it possible to port over the Rails migration generators? They seem pretty modular and separate from the rest of the Rails source code:

https://github.com/rails/rails/tree/master/activerecord/lib/rails/generators

Paper Trail Upgrading to 4.0.0 Broken

Using latest 4.0.0 branch with Napa (currently only works with 3.X branch) breaks, with the addition of PaperTrail::VersionAssociation

NameError: uninitialized constant PaperTrail::VersionAssociation
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/config.rb:33:in `track_associations'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/version_concern.rb:14:in `block in <module:VersionConcern>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/activesupport-4.0.13/lib/active_support/concern.rb:114:in `class_eval'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/activesupport-4.0.13/lib/active_support/concern.rb:114:in `append_features'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb:5:in `include'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb:5:in `<class:Version>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb:4:in `<module:PaperTrail>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb:3:in `<top (required)>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record.rb:4:in `require'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record.rb:4:in `block in <top (required)>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record.rb:3:in `each'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail/frameworks/active_record.rb:3:in `<top (required)>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail.rb:155:in `require'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/gems/paper_trail-4.0.0.rc1/lib/paper_trail.rb:155:in `<top (required)>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:76:in `require'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:72:in `each'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:72:in `block in require'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:61:in `each'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler/runtime.rb:61:in `require'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@global/gems/bundler-1.7.11/lib/bundler.rb:134:in `require'
/Users/ericpkerr/Code/hacktime/people-service/app.rb:5:in `<top (required)>'
/Users/ericpkerr/Code/hacktime/people-service/Rakefile:6:in `require'
/Users/ericpkerr/Code/hacktime/people-service/Rakefile:6:in `<top (required)>'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/bin/ruby_executable_hooks:15:in `eval'
/Users/ericpkerr/.rvm/gems/ruby-2.0.0-p598@people-service/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)

Integrate StatsD Client LIbrary

Which library is totally up for debate, ideally one that integrates ActiveRecord data. Napa should easily present developers with a generated statsd namespace and some canned metrics.

Ideas for canned metrics:

  • Response Time for Request Fulfillment
  • Counter for Response Requests

Allow eager autoloading

In a multi-threaded environment we are seeing circular dependency exceptions (usually around representer classes).

Rails suffers from the same problem, but in production a rails app will use eager autoloading to prevent it. However, this doesn't seem to hold for Napa since we are seeing the same issue in production.

I have spent some time trying to find a way to force eager autoloading in Napa, but nothing seemed to work. Is there already a simple way to enable eager autoloading or will this require an update to Napa?

Active Record Text datatype

I'm getting the following error for the Active Record Text datatype:

NameError: uninitialized constant UsersApi::Text

rake db:seed throws error

bundle exec rake db:seed
#=> rake db:seedNameError: uninitialized constant Napa::ActiveRecordSeeder

Unable to use Mongoid with Napa Representer

I'm trying to use Mongoid as my service makes more sense to use a document store rather than a SQL database. Mongoid has a find() method which returns a single class, but the Napa Representer chokes on this. I believe that Napa is trying to do some magic and getting confused about the type of object that Mongoid is returning. Any advice? Here is the dump of the error:

NoMethodError: undefined method `map' for #<Message:0x007f7f6ab436b0>
    /var/lib/gems/2.2.0/gems/napa-0.4.3/lib/napa/grape_extensions/grape_helpers.rb:7:in `represent'
    /vagrant/messages-service/app/apis/messages_v1_api.rb:100:in `block (3 levels) in <class:MessagesV1Api>'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:47:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:47:in `block in generate_api_method'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:247:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:247:in `run'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:195:in `block in call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/base.rb:24:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/base.rb:24:in `call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/base.rb:18:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/base.rb:24:in `call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/base.rb:18:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/error.rb:27:in `block in call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/error.rb:26:in `catch'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/error.rb:26:in `call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/middleware/base.rb:18:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/head.rb:13:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/builder.rb:153:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:196:in `call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/endpoint.rb:184:in `call'
    /var/lib/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
    /var/lib/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
    /var/lib/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:89:in `optimized_each'
    /var/lib/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
    /var/lib/gems/2.2.0/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/api.rb:98:in `call'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/api.rb:33:in `call!'
    /var/lib/gems/2.2.0/gems/grape-0.11.0/lib/grape/api.rb:29:in `call'
    /var/lib/gems/2.2.0/gems/napa-0.4.3/lib/napa/middleware/app_monitor.rb:12:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/lint.rb:49:in `_call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/lint.rb:37:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/showexceptions.rb:24:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/commonlogger.rb:33:in `call'
    /var/lib/gems/2.2.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:86:in `proceed_as_child'
    /var/lib/gems/2.2.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:31:in `call!'
    /var/lib/gems/2.2.0/gems/shotgun-0.9.1/lib/shotgun/loader.rb:18:in `call'
    /var/lib/gems/2.2.0/gems/shotgun-0.9.1/lib/shotgun/favicon.rb:12:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/urlmap.rb:66:in `block in call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/urlmap.rb:50:in `each'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/urlmap.rb:50:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/builder.rb:153:in `call'
    /var/lib/gems/2.2.0/gems/rack-1.6.1/lib/rack/handler/webrick.rb:89:in `service'
    /usr/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
    /usr/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
    /usr/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

rake db:reset throws error

After creating a new napa service on bundle install everything works fine. But when we try to create a database using rake db:create --trace, it throws the following error,

WARN: Unresolved specs during Gem::Specification.reset:
      minitest (~> 4.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
rake aborted!
NameError: uninitialized constant Virtus::Configuration::Coercible
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus/configuration.rb:40:in `initialize'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus/builder.rb:28:in `new'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus/builder.rb:28:in `call'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/virtus-1.0.5/lib/virtus.rb:152:in `model'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/representable-1.8.5/lib/representable/coercion.rb:5:in `<class:Coercer>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/representable-1.8.5/lib/representable/coercion.rb:4:in `<module:Coercion>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/representable-1.8.5/lib/representable/coercion.rb:3:in `<top (required)>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/roar-0.12.9/lib/roar/representer/feature/coercion.rb:2:in `require'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/roar-0.12.9/lib/roar/representer/feature/coercion.rb:2:in `<top (required)>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/napa-0.4.3/lib/napa/output_formatters/representer.rb:3:in `require'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/napa-0.4.3/lib/napa/output_formatters/representer.rb:3:in `<top (required)>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/napa-0.4.3/lib/napa.rb:27:in `require'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/napa-0.4.3/lib/napa.rb:27:in `<top (required)>'
/home/jay/AppService/app.rb:6:in `require'
/home/jay/AppService/app.rb:6:in `<top (required)>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
/home/jay/AppService/Rakefile:6:in `<top (required)>'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `load'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:94:in `block in load_rakefile'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:93:in `load_rakefile'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:77:in `block in run'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/jay/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/jay/.rbenv/versions/2.0.0-p576/bin/rake:23:in `load'
/home/jay/.rbenv/versions/2.0.0-p576/bin/rake:23:in `<main>'


rake aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)

I was able to create a new napa project and install the dependencies. Now when I do

rake db:reset

it throws the following error.

WARN: Unresolved specs during Gem::Specification.reset:
      rack (>= 0.4, >= 1.0, >= 1.0.0, >= 1.3.0)
      builder (>= 0)
      actionpack (>= 3.2)
      json (>= 1.7.7, ~> 1.7)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
rake aborted!
Gem::LoadError: You have already activated minitest 5.6.1, but your Gemfile requires minitest 4.7.5. Prepending `bundle exec` to your command may solve this.
/home/jay/NapaServ/app.rb:2:in `<top (required)>'
/home/jay/NapaServ/Rakefile:6:in `<top (required)>'
(See full trace by running task with --trace)

So, I prepend bundle exec to the command.

bundle exec rake db:reset

But this time throws the following error

rake aborted!
Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)

Tasks: TOP => db:drop

The above error is quite weird because inside the project in the .env file the configurations are as follows

DATABASE_USER='rooty'
DATABASE_PASSWORD='root'
DATABASE_HOST=localhost
DATABASE_NAME=napaTest

As seen the username is rooty but the error shows root. So am I configuring the connections in the right file or is it something else

Swagger throwing undefined method `collect' for nil:NilClass

it appears grape-swagger doesn't support grapes use of the route_param block

This code works fine.

 desc 'Delete a question'
 params do
   requires :id, desc: 'ID of the question'
 end
 delete ':id' do
   Question.find(params[:id]).delete
   { success: true }
 end

This code below throws an error.

route_param :id do
   delete do
     Question.find(params[:id]).delete
     { success: true }
   end
 end

I'm logging this as an issue because the way we use Napa at Belly and the official grape examples result in this error. And it took me several hours to figure out what the cause was. Hopefully this helps someone else.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.