All Projects → crepe → Crepe

crepe / Crepe

The thin API stack.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Crepe

Kemal
Fast, Effective, Simple Web Framework
Stars: ✭ 3,227 (+2589.17%)
Mutual labels:  api, fast
Rack App
minimalist framework for building rack applications
Stars: ✭ 389 (+224.17%)
Mutual labels:  api, rack
Light 4j
A fast, lightweight and more productive microservices framework
Stars: ✭ 3,303 (+2652.5%)
Mutual labels:  lightweight, fast
brisk-ioc
fast light brisk ioc/di container on nodejs; Node下快速 轻量的IoC/DI容器,依赖注入,配合装饰器使用
Stars: ✭ 12 (-90%)
Mutual labels:  fast, lightweight
Utox
µTox the lightest and fluffiest Tox client
Stars: ✭ 820 (+583.33%)
Mutual labels:  lightweight, fast
Metrics
Lightweight alternative to github.com/prometheus/client_golang
Stars: ✭ 254 (+111.67%)
Mutual labels:  lightweight, fast
Wondercms
WonderCMS - fast and small flat file CMS (5 files)
Stars: ✭ 330 (+175%)
Mutual labels:  lightweight, fast
ios-application
A native, lightweight and secure one-time-password (OTP) client built for iOS; Raivo OTP!
Stars: ✭ 581 (+384.17%)
Mutual labels:  fast, lightweight
Maquette
Pure and simple virtual DOM library
Stars: ✭ 729 (+507.5%)
Mutual labels:  lightweight, fast
Agoo
A High Performance HTTP Server for Ruby
Stars: ✭ 679 (+465.83%)
Mutual labels:  fast, rack
sabotage
a radical and experimental distribution based on musl libc and busybox
Stars: ✭ 502 (+318.33%)
Mutual labels:  fast, lightweight
Xseries
Library for cross-version Minecraft Bukkit support and various efficient API methods.
Stars: ✭ 109 (-9.17%)
Mutual labels:  api, fast
AutoMagic
A magically fast, lightweight and customizable javascript library.
Stars: ✭ 16 (-86.67%)
Mutual labels:  fast, lightweight
Framework
Swoole, PSR-15, PSR-7, PSR-11 lightweight modular anti-framework for REST micro-services.
Stars: ✭ 259 (+115.83%)
Mutual labels:  lightweight, fast
jobflow
runs stuff in parallel (like GNU parallel, but much faster and memory-efficient)
Stars: ✭ 67 (-44.17%)
Mutual labels:  fast, lightweight
Autocomplete.js
Simple autocomplete pure vanilla Javascript library.
Stars: ✭ 3,428 (+2756.67%)
Mutual labels:  lightweight, fast
tinyrpc
Much fast, lightweight, async, based boost.beast and protobuf.
Stars: ✭ 32 (-73.33%)
Mutual labels:  fast, lightweight
brute-md5
Advanced, Light Weight & Extremely Fast MD5 Cracker/Decoder/Decryptor written in Python 3
Stars: ✭ 16 (-86.67%)
Mutual labels:  fast, lightweight
Domvm
DOM ViewModel - A thin, fast, dependency-free vdom view layer
Stars: ✭ 581 (+384.17%)
Mutual labels:  lightweight, fast
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+697.5%)
Mutual labels:  api, fast

Crepe Build Status Code Climate

Crepe is a lightweight API framework designed to help you write clean, fast web services in Ruby. With an elegant and intuitive DSL inspired by RSpec, and with a nod to Grape, Crepe makes API design simple.

Installation

In your application's Gemfile:

gem 'crepe', github: 'crepe/crepe'

If you're coming from Rails and/or you want a Crepe application with a thought-out file structure, you can use creperie to generate a new API:

$ gem install creperie --pre
$ crepe new my_api

Usage

Crepe APIs are, at their core, Rack applications. They can be created by subclassing Crepe::API. To detail Crepe's major features, we'll show how GitHub's Gist API could be written using Crepe:

# config.ru
require 'bundler/setup'
require 'crepe'

module Gist
  class API < Crepe::API
    # Like `let` in RSpec, this defines a lazy-loading helper.
    let(:current_user) { User.authorize!(request.headers['Authorization']) }

    namespace :gists do
      let(:gist_params) { params.slice(:files, :description, :public) }

      get do
        begin
          current_user.gists.limit(30)
        rescue User::Unauthorized
          Gist.limit(30)
        end
      end

      post { Gist.create(gist_params) }

      get(:public) { Gist.limit(30) }

      get(:starred) { current_user.starred_gists }

      # Specify a parameter as part of the namespace: /gists/:id/...
      param :id do
        let(:gist) { Gist.find(params[:id]) }

        get    { gist }
        put    { gist.update_attributes(gist_params) }
        patch  { gist.update_attributes(gist_params) }
        delete do
          if gist.user == current_user
            gist.destroy and head :no_content
          else
            error! :unauthorized
          end
        end

        # Specify a parameter constraint, e.g. a 40-character hex string
        param(sha: /\h{40}/) { gist.revisions.find(params[:sha]) }
        get(:commits) { gist.commits.limit(30) }

        get :star do
          if current_user.starred?(gist)
            head :no_content
          else
            head :not_found
          end
        end
        put(:star)    { current_user.star(gist) }
        delete(:star) { current_user.unstar(gist) }

        get(:forks)  { gist.forks.limit(30) }
        post(:forks) { current_user.fork(gist) }
      end
    end

    rescue_from ActiveRecord::RecordNotFound do |e|
      error! :not_found, e.message
    end

    rescue_from ActiveRecord::InvalidRecord do |e|
      error! :unprocessable_entity, e.message, errors: e.record.errors
    end

    rescue_from User::Unauthorized do |e|
      unauthorized! realm: 'Gist API'
    end
  end
end

run Gist::API

The above example will give you a Rack application that you can run with the rackup command, responding to the following routes:

GET    /gists
POST   /gists
GET    /gists/public
GET    /gists/starred
GET    /gists/:id
PUT    /gists/:id
PATCH  /gists/:id
DELETE /gists/:id
GET    /gists/:id/:sha
GET    /gists/:id/commits
GET    /gists/:id/star
PUT    /gists/:id/star
DELETE /gists/:id/star
GET    /gists/:id/forks
POST   /gists/:id/forks

Advanced usage

The above example only skims the surface of what Crepe can do. For more information, see the Crepe wiki.

License

(The MIT License.)

© 2013–2015 Stephen Celis [email protected], Evan Owen [email protected], David Celis [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].