Project

fasta

0.0
No release in over 3 years
Low commit activity in last 3 years
Rack Server API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 13.0
~> 3.0

Runtime

~> 2.0.0.alpha3
~> 1
~> 3
~> 1
~> 4
~> 2
~> 5
~> 1
 Project Readme

Fasta

Just a mini web framework

Installation

 $ gem install fasta
 $ fasta plz NEW_APP_NAME
 $ cd NEW_APP_NAME

Start

Before first start run

 $ rake db:create

To start server:

 $ fasta go [-e ENVIRONMENT] [-p PORT]

or advanced

 $ puma boot.ru -e production -p 3210

Add Endpoint

 $ fasta endpoint <ENDPOINT_NAME> <ACTION> <ACTION> <ACTION> ... 
 # fasta endpoint account index show custom

After generate endpoint add the appropriate routes in routes.rb and extend a migration with needed fields:

 # routes.rb

 $router = Fasta::Router.new do |mapper|
   ...
   mapper.reg(:<METHOD>, '/<PATH>', <ENDPOINT>::<ACTION>)  
   
 # mapper.reg(:get, '/accounts', Account::Index)
   ...
 end  

Also after set up migration file run:

 $ rake db:migrate

Associated Entities

    # app/endpoints/user/boards.rb

    module User
      class Boards < Model::Show
        validate_fields :id
        
        def fetch
          user_id = params[:id]
          through = DB[:users_boards].where(user_id: user_id)
          DB[:boards].where(id: through.select(:board_id)).to_a
        end
      end
    end
    # routes.rb
    $router = Fasta::Router.new do |mapper|
      ...
      mapper.reg(:get, '/users/:id/boards', User::Boards) 
      ...
    end

Namespaces

    # app/endpoints/team/user.rb
    
    module Team
      module User
        extend Model
      end
    end
 
    # app/endpoints/team/user/index.rb
    
    module Team
      module User
        class Index < Model::Index; end
      end
    end 
    # routes.rb
    $router = Fasta::Router.new do |mapper|
      ...
      mapper.reg(:get, 'team/users', Team::User::Index)
      ...
    end  

Usage

TODO:

  1. Write usage instructions here
  2. Show and Index considering