-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate API Key auth support generation (#124)
## Problem The generator `stitches:api` forces adding in API Key auth support. ## Solution Introduce a new generator `stitches:api_migration` that can add in API Key auth support.
- Loading branch information
Showing
9 changed files
with
50 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'rails/generators' | ||
|
||
module Stitches | ||
class ApiMigrationGenerator < Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
|
||
source_root(File.expand_path(File.join(File.dirname(__FILE__), "generator_files"))) | ||
|
||
def self.next_migration_number(path) | ||
Time.now.utc.strftime("%Y%m%d%H%M%S") | ||
end | ||
|
||
desc "Add a DB backed key storage system for your API service" | ||
def bootstrap_api_migration | ||
copy_file "app/models/api_client.rb" | ||
copy_file "lib/tasks/generate_api_key.rake" | ||
|
||
migration_template "db/migrate/enable_uuid_ossp_extension.rb", "db/migrate/enable_uuid_ossp_extension.rb" | ||
sleep 1 # allow clock to tick so we get different numbers | ||
migration_template "db/migrate/create_api_clients.rb", "db/migrate/create_api_clients.rb" | ||
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
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