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

generator-es6-graphql

v0.8.0

Published

This generator enables you to quickly create an ES6 (ES2105) GraphQL enabled server with a lot of optional additions.

Downloads

10

Readme

generator-es6-graphql

npm version Build Status Dependency Status

This yeoman generator enables you to quickly create an ES6 (ES2105) graphql enabled server with a lot of optional additions.

Goal

The goal of this yeoman generator is to enable you to quickly set up an ES6 (ES2105) enabled GraphQL server without dependencies you do not need.

This means that the choice of for example database and testing framework is up to you, although some choices are available during setup to make your life easier:

  • mongoose as database
  • passport for authentication
  • local authentication with basic user model skeleton
  • persistent sessions if mongoose and authentication are enabled

Installation

Install yo and the generator globally by running:

sudo npm install -g yo generator-es6-graphql

Create a directory for your new project and run the generator:

mkdir yourProject
cd yourProject
yo es6-graphql

To start your newly generated GraphQL server on port 1234 run:

npm start

First steps

If you chose to enable GraphiQL you can now browse to your GraphQL endpoint and play around with the Documentation Explorer or invoke your own queries:

{
  getItem(id: 1){
    id,
    name
  }
}

Authentication

If you chose to enable authentication and selected at least one OAuth strategy, do not forget to add your API credentials for the chosen services to src/passportConfig.js.

Local Authentication

If you chose to enable a database and local authentication, you will get a basic User model and routes for authentication.

User model

The User model is very basic and only has the following fields:

  • _id
  • username
  • password

The Model also provides functionality to check if passwords match and to store passwords encrypted via bcrypt.

/login (POST)

Parameters:

  • username
  • password

Returns:

  • 200 if user could be logged
  • 400 if parameters are missing
  • 401 if credentials do not match
/logout (GET)

Logs out a user and destroys his session.

Usage

Open GraphiQL and run:

{
  users {_id, username, mail},
  self {_id, username, mail}
}

You will see that users is an empty array and self is null, this is because there are no users signed up yet and you are not logged in.

Sign up a user via mutation:

mutation {
  signup(username: "username", password: "password") {
    _id,
    username
  }
}

Now login via the route mentioned above and query the user and self again. The users array still has one user, but now self should contain information about the currently logged in user.

In a similar way you can now set your E-Mail address:

mutation {
  updateEmail(mail: "[email protected]") {
    _id,
    username,
    mail
  }
}

If you open the logout route mentioned above and run the commands again, self is null again.

Development

This generator is work in progress, feel free to submit issues if you have a problem or PR's if you want to contribute.

Tests are in place and may be run by invoking:

npm run test

Versioning

The version of the npm package reflects the current master branch. If you want to check out bleeding edge functionality check out the dev branch.