refactor: rename src folder with app
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
module App::Lib
|
||||
abstract class BaseController
|
||||
def map_changeset_errors(errors)
|
||||
errors.reduce({} of String => Array(String)) do |memo, error|
|
||||
memo[error[:field]] = memo[error[:field]]? || [] of String
|
||||
memo[error[:field]] << error[:message]
|
||||
memo
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
require "sqlite3"
|
||||
require "crecto"
|
||||
|
||||
module App::Lib
|
||||
class Database
|
||||
extend Crecto::Repo
|
||||
|
||||
Query = Crecto::Repo::Query
|
||||
Multi = Crecto::Repo::Multi
|
||||
|
||||
config do |conf|
|
||||
conf.uri = ENV["DATABASE_URL"]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,26 @@
|
||||
require "kemal"
|
||||
|
||||
module App
|
||||
class BadRequestException < Kemal::Exceptions::CustomException
|
||||
def initialize(context)
|
||||
context.response.status_code = 400
|
||||
super(context)
|
||||
end
|
||||
end
|
||||
|
||||
class NotFoundException < Kemal::Exceptions::CustomException
|
||||
def initialize(context)
|
||||
context.response.status_code = 404
|
||||
super(context)
|
||||
end
|
||||
end
|
||||
|
||||
class UnprocessableEntityException < Kemal::Exceptions::CustomException
|
||||
def initialize(context, @content = "")
|
||||
context.response.status_code = 422
|
||||
super(context)
|
||||
end
|
||||
|
||||
getter :content
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user