All Projects → oslabs-beta → Portara

oslabs-beta / Portara

Licence: mit
Portara directive is a rate limiter / throttler for GraphQL

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Portara

Fullstack Boilerplate
Fullstack boilerplate using Typescript, React, GraphQL
Stars: ✭ 181 (+14.56%)
Mutual labels:  graphql, apollo, redis
Awesome Apollo Graphql
A curated list of amazingly awesome things regarding Apollo GraphQL ecosystem 🌟
Stars: ✭ 126 (-20.25%)
Mutual labels:  graphql, apollo, apollo-server
Sqldatasource
SQL DataSource for Apollo GraphQL projects
Stars: ✭ 176 (+11.39%)
Mutual labels:  graphql, apollo, apollo-server
Chatty
A WhatsApp clone with React Native and Apollo (Tutorial)
Stars: ✭ 481 (+204.43%)
Mutual labels:  graphql, apollo, apollo-server
Graphql Advanced Projection
Fully customizable Mongoose/MongoDB projection generator.
Stars: ✭ 46 (-70.89%)
Mutual labels:  graphql, apollo, apollo-server
React Hipstaplate
A ReactJS full-stack boilerplate based on typescript with ssr, custom apollo-server and huge stack of modern utilities which will help you to start your own project
Stars: ✭ 74 (-53.16%)
Mutual labels:  graphql, apollo, apollo-server
Firestore Apollo Graphql
An example of a GraphQL setup with a Firebase Firestore backend. Uses Apollo Engine/Server 2.0 and deployed to Google App Engine.
Stars: ✭ 371 (+134.81%)
Mutual labels:  graphql, apollo, apollo-server
Graphql Modules
Enterprise Grade Tooling For Your GraphQL Server
Stars: ✭ 962 (+508.86%)
Mutual labels:  graphql, apollo, apollo-server
Graphql Apq
🎯 Automatic persisted queries (APQ) for any GraphQL server.
Stars: ✭ 43 (-72.78%)
Mutual labels:  graphql, apollo, apollo-server
Apollo Server Vercel
⚫ Production-ready Node.js GraphQL server for Vercel Serverless Functions
Stars: ✭ 69 (-56.33%)
Mutual labels:  graphql, apollo, apollo-server
Quell
Quell is an easy-to-use, lightweight JavaScript library providing a client- and server-side caching solution for GraphQL. Use Quell to prevent redundant client-side API requests and to minimize costly server-side response latency.
Stars: ✭ 90 (-43.04%)
Mutual labels:  graphql, apollo, redis
Apollo Universal Starter Kit
Apollo Universal Starter Kit is an SEO-friendly, fully-configured, modular starter application that helps developers to streamline web, server, and mobile development with cutting-edge technologies and ultimate code reuse.
Stars: ✭ 1,645 (+941.14%)
Mutual labels:  graphql, apollo
Join Monster Graphql Tools Adapter
Use Join Monster to fetch your data with Apollo Server.
Stars: ✭ 130 (-17.72%)
Mutual labels:  graphql, apollo
Next Advanced Apollo Starter
Advanced, but minimalistic Next.js pre-configured starter with focus on DX
Stars: ✭ 131 (-17.09%)
Mutual labels:  graphql, apollo
Graphql Cli
📟 Command line tool for common GraphQL development workflows
Stars: ✭ 1,814 (+1048.1%)
Mutual labels:  graphql, apollo
React Redux Graphql Apollo Bootstrap Webpack Starter
react js + redux + graphQL + Apollo + react router + hot reload + devTools + bootstrap + webpack starter
Stars: ✭ 127 (-19.62%)
Mutual labels:  graphql, apollo
Jiiiiiin Security
一个前后端分离的内管基础项目
Stars: ✭ 132 (-16.46%)
Mutual labels:  apollo, redis
Micro Medium Api
Microservice for fetching the latest posts of Medium with GraphQL.
Stars: ✭ 138 (-12.66%)
Mutual labels:  graphql, apollo-server
Java Apollo
关于自己的一些学习文档和学习心得都放在这里啦!!!
Stars: ✭ 140 (-11.39%)
Mutual labels:  apollo, redis
Apollo Opentracing
Performance trace your Apollo GraphQL server with Opentracing
Stars: ✭ 154 (-2.53%)
Mutual labels:  graphql, apollo-server

Portara

Overview

Portara is an open source rate limiter designed for easy use with Apollo Server, including other Apollo implementations (including Apollo-Server-Express, Apollo-Server-Hapi, Apollo-Server-Koa, and Apollo-Server-Lambda). By using GraphQL Directives, developers have the ability to easily implement multiple rate limiters with as little as four lines of code.

Requirements

  • Node.js version 8.0.0+

  • Redis version 2.6.12+

Install

With npm:

npm install --save portara

Note: Redis is a requirement for this package. You can visit Redis' Getting Started Page for information on getting started with Redis. If you are using multiple servers (or the serverless framework), we recommend using Redis Cloud.

Getting Started

  • [ ] 1. Import Portara into your server file:
import Portara from 'portara';

  • [ ] 2. Add to your Apollo Server (make sure BOTH the context and schemaDirectives are added:
const server = new ApolloServer({
  typeDefs,
  resolvers,
  context: ({ req, res }) = ({ req, res }),
  schemaDirectives: { portara: portara("TOKEN GOES BETWEEN THESE QUOTES") },
});

The token is optional. You can get a token from Portara.io with a quick sign up throught Github Oauth. The token grants access to modify your rate limiter / throttler without redeploying your app. If you do not plan on using this feature, leave the parameter empty.

  • [ ] 3. Add the directive @portara to your type definitions (copy line below):
const typeDefs = gql`
  directive @portara(limit: Int!, per: ID!, throttle: ID!) on FIELD_DEFINITION | OBJECT
  
  type Query { etc...

  • [ ] 4. You can type out exactly how you want the rate limiter to work in plain English. Please note that the usage of any strings must be in DOUBLE QUOTES, and values default to seconds. Below are a few examples:

  • On Object Type

    • This implementation applies the Portara rate limiter on the entire Query Object (which includes the "hello" and "goodbye" field definitions).

    • The rate limiter limits 10 requests to the endpoint (per IP address) per every 5 seconds.

type Query @portara(limit: 10, per: "5 seconds", throttle: "0") {
  hello: String!
  goodbye: String!
}
  • Throttling

    • Throttling is an option. If throttling is turned on with any truthy values such as (throttle: "500ms"), it will no longer block requests. However, it will allow requests to come in at the time frame passed in. In this case, every 500 miliseconds.
  • On Field Type

    • This implementation applies the Portara rate limiter on just the Field Defintion (just the "hello").

    • The rate limiter limits 300 requests to the endpoint (per IP address) per every 12 minutes.

type Query {
  hello: String! @portara(limit: 300, per: "12 minutes", throttle: 0) 
  goodbye: String!
}
  • On Both

    • If portara is applied to both object and field levels, the field will override any object level that's being applied to it. For the example below, "hello" would have a limit of 15, and "bye" would have a limit of 10.
type Query @portara(limit: 10, per: "5 seconds", throttle: 0) {
  hello: String! @portara(limit: 15, per: "5 seconds", throttle: 0)
  goodbye: String!
}
  • Other Time Measurements

    • The time measurements supported are:
      • Milliseconds: (can be typed as: ms, millisecond, milliseconds, mil, mils)
      • Seconds: (can be typed as: second, seconds, sec, or secs)
      • Minutes: (can be typed as: minute, minutes, min, or mins)
      • Hours: (can be typed as: hour, hours, or h)
      • Days: (can be typed as: day, days, or d)
      • Weeks: (can be typed as: week, weeks,or w)
type Query @portara(limit: 12, per: "5 h", throttle: 0) {
 hello: String! @portara(limit: 20, per: "94 ms", throttle: 0)
 goodbye: String! @portara(limit: 90, per: "2 minutes", throttle: 0)
 thankyou: String!
}
  • [ ] Lastly, Connect with the Portara Team!

@Portara

[email protected]

Steve Frend: Steve's Github and Steve's LinkedIn

Todd Alexander: Todd's Github and Todd's LinkedIn

Cary L Chan: Cary's Github and Cary's LinkedIn

Alexander Infante: Alex's Github and Alex's LinkedIn

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].