-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
57 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module API | ||
module Helpers | ||
def logger | ||
Root.logger | ||
module GrapeApiBoilerplate | ||
module Api | ||
module Helpers | ||
def logger | ||
Root.logger | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
module API | ||
class Root < Grape::API | ||
format :json | ||
default_format :json | ||
content_type :json, 'application/json' | ||
prefix :api | ||
module GrapeApiBoilerplate | ||
module Api | ||
class Root < Grape::API | ||
format :json | ||
default_format :json | ||
content_type :json, 'application/json' | ||
prefix :api | ||
|
||
rescue_from :grape_exceptions | ||
rescue_from :grape_exceptions | ||
|
||
# Logging | ||
insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, | ||
{ | ||
logger:, | ||
formatter: GrapeLogging::Formatters::Json.new, | ||
include: [GrapeLogging::Loggers::FilterParameters.new([:password])] | ||
} | ||
# Logging | ||
insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, | ||
{ | ||
logger:, | ||
formatter: GrapeLogging::Formatters::Json.new, | ||
include: [GrapeLogging::Loggers::FilterParameters.new([:password])] | ||
} | ||
|
||
# Helpers | ||
helpers do | ||
include Helpers | ||
end | ||
# Helpers | ||
helpers do | ||
include Helpers | ||
end | ||
|
||
# Routes | ||
mount GrapeApiBoilerplate::Api::Endpoints::Session | ||
mount GrapeApiBoilerplate::Api::Endpoints::V1::HelloWorldEndpoint | ||
mount GrapeApiBoilerplate::Api::Endpoints::V1::WidgetEndpoint | ||
# Routes | ||
mount GrapeApiBoilerplate::Api::Endpoints::Session | ||
mount GrapeApiBoilerplate::Api::Endpoints::V1::HelloWorldEndpoint | ||
mount GrapeApiBoilerplate::Api::Endpoints::V1::WidgetEndpoint | ||
|
||
add_swagger_documentation \ | ||
info: { | ||
title: 'Grape Boilerplate', | ||
description: 'A full-featured API boilerplate to get you started with the Grape framework.' | ||
} | ||
add_swagger_documentation \ | ||
info: { | ||
title: 'Grape Boilerplate', | ||
description: 'A full-featured API boilerplate to get you started with the Grape framework.' | ||
} | ||
|
||
# Handle 404s | ||
route :any, '*path' do | ||
error!({ message: 'resource does not exist' }, 404) | ||
# Handle 404s | ||
route :any, '*path' do | ||
error!({ message: 'resource does not exist' }, 404) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'rack/cors' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters