npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@britishcouncil/grizzly

v0.3.3

Published

Slightly opinionated GraphQL server solution.

Downloads

16

Readme

@britishcouncil/grizzly

Slightly opinionated GraphQL server solution built on Apollo Server, PostGraphile and Express.

Overview

  • All the features of the latest Apollo Server, plus
  • All the features of the latest PostGraphile
  • Create multiple GraphQL services (i.e. Apollo or PostGraphile services) over a single Express application

Install

yarn add @britishcouncil/grizzly # npm install @britishcouncil/grizzly

Usage

Quickstart

To get started with @britishcouncil/grizzly, have a look at the examples.

API

GrizzlyExpress

constructor(props: GrizzlyExpressProps): GrizzlyExpress

The props argument accepts the following fields:

| Key | Type | Default | Notes | | ----------------- | ------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | graphqlServices | Array of GrizzlyGraphQLServer | null | See GrizzlyGraphQLServer documentation below for more details about this type | | sessionStore | Store | null | An instance of a session storage for Express server. | | passport | Authenticator | null | An instance of a passport authenticator. | | middlewares | Array of ExpressMiddleware | null | Each ExpressMiddleware can have a path (optional) and a function, e.g. { path: "/hello-world", function: () => "Hello world!" } or { function: () => console.log("Everything") } | | port | string or number | process.env.PORT or 5000 | HTTP server port. | | host | host | See https://nodejs.org/api/net.html#net_server_listen | HTTP server binding address. | | session | SessionOptions | { secret: process.env.SESSION_SECRET, cookie: { maxAge: 3600000 } // 3600000ms = 1h. } | Sessions options | | cors | CorsOptions | null | Cors configuration. | | bodyParse | Object or boolean | false | The body-parser options: false removes the body parser middleware and true uses the defaults |

GrizzlyApollo

constructor(options: GrizzlyApolloConfig): GrizzlyApollo

The options argument accepts all the parameters as the options argument by Apollo Server 2.0, but it also adds:

| Key | Type | Default | Notes | | ------------- | --------------------------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | schemaFile | string | null | Path to a GraphQL schema written in SDL. If this parameter is specified, there will be no need to specify either typeDefs or schema (see Apollo Server options) | | endpoint | string | "/graphql" | The endpoint with which register the GraphQL service to the Express app. | | middlewares | array of GraphQLMiddleware | null | |

GrizzlyPostGraphile

constructor(options: GrizzlyPostGraphileOptions): GrizzlyPostGraphile

The options argument accepts all the parameters as the options argument by postgraphile() (see also PostGrpahileOptions interface), but it also merges into it the other two parameters of the postgraphile() function:

| Key | Type | Default | Notes | | ------------ | ---------------------------------- | ----------- | ---------------------------------------------------- | | pgConfig | Pool or PoolConfig or string | null | PostgreSQL connection string or object. | | schemaName | string or Array<string> | "public" | PostgreSQL schema(s) you to expose via PostGraphile. |

Types

/**
 * Session options.
 */
export interface SessionOptions {
  secret?: string;
  cookie?: CookieOptions;
}

/**
 * General interace for GraphQL servers.
 */
export interface GrizzlyGraphQLServer {
  endpoint?: string;
  applyMiddleware({
    app,
    path,
    cors,
    bodyParserConfig,
    disableHealthCheck,
    onHealthCheck
  }: ServerRegistration): void;
}

/**
 * Type for express middlewares. Path is optional.
 */
export interface ExpressMiddleware {
  path?: string;
  function: Function;
}

/**
 * Grizzly Express initialisation options.
 */
export interface GrizzlyExpressProps {
  graphqlServices: Array<GrizzlyGraphQLServer>;
  sessionStore?: Store;
  passport?: Authenticator;
  middlewares?: Array<ExpressMiddleware>;
  port?: string | number;
  address?: string;
  cors?: CorsOptions;
  session?: SessionOptions;
  bodyParser?: Object | boolean;
}

/**
 * Extends ApolloServer Config.
 */
export interface GrizzlyApolloConfig extends ApolloConfig {
  schemaFile?: string;
  endpoint?: string;
  middlewares?: Array<any>;
}

/**
 * Extends PostGraphile Config.
 */
export interface GrizzlyPostGraphileOptions extends PostGraphileOptions {
  pgConfig?: Pool | PoolConfig | string;
  schemaName?: string | Array<string>;
}