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 🙏

© 2026 – Pkg Stats / Ryan Hefner

zaife

v3.5.1

Published

GraphQL Koa Server using Mongoose as a database.

Readme

zaife /zīf/

A simple GraphQL Koa server using MongoDB as database.

Quickstart

Install

npm install --save zaife

Example

Given the following arbitrary* file structure for the examples below:

+-- server.js
+-- types
|   +-- user.gql
|   +-- scalar.gql
+-- resolvers
|   +-- userMutations.js
|   +-- userQueries.js
|   +-- scalars
|   |   +-- date.js
|   |   +-- email.js
+-- models
|   +-- user.js

*You can design your own file structure to your liking.

Server

In file server.js,

import { Server } from 'zaife';

const server = new Server({
  port: 3000,
  host: 'localhost',
  mongoUri: 'mongodb://localhost:27017/appname',
  pathToModels: './models',
  pathToResolvers: './resolvers',
  pathToTypes: './types'
});

server.start(); // .start() is an async function

Mongoose Models

You can have multiple model files in any path structure you like under the directory you specified in options.pathToModels. The models are automatically loaded and are accessible from zaife module.

In file models/user.js,

import mongoose, { Schema } from 'mongoose';

const schema = new Schema({
  email: { type: String, unique: true, required: true }
});

schema.index({ email: 1 }, { unique: true });
mongoose.model('User', schema);

Graphql Schema Files

Your graphql schemas can be structured in separate files in any path structure you like as long as they are under the directory you specified in options.pathToTypes.

In file types/user.gql,

type User {
  _id: ID!
  email: String!
}

type Mutation {
  createUser(email: String!): User!
}

type Query {
  getUser(_id: ID!): User
}

In file types/scalar.gql,

scalar DateTime
scalar Email

Resolvers and Accessing Models

You can have multiple resolver files in any path structure you like under the directory you specified in options.pathToResolvers.

In file resolvers/userMutations.js,

import { Models } from 'zaife';

const UserModel = Models('User');

const Mutation = {
  async createUser(parent, args, ctx, info) {
    return new UserModel(args).save();
  }
};

module.exports = { Mutation };

In file resolvers/userQueries.js,

import { Models } from 'zaife';

const UserModel = Models('User');

const Query = {
  async getUser(parent, args, ctx, info) {
    return UserModel.findOne(args);
  }
};

module.exports = { Query };

In file resolvers/scalars/date.js,

import Scalars from 'zaife';

export default {
  DateTime: Scalars.GraphQLDateTime,
};

In file resolvers/scalars/email.js,

import Scalars from 'zaife';

export default {
  Email: Scalars.GraphQLEmail,
};

Docs

Class: Zaife.Server

const server = new Server(options)

Initializes the server configuration.

  • options.port? <number> - HTTP port to be used. Default: process.env.PORT || 3000
  • options.host? <string> - HTTP host to be used. Default: process.env.HOST || 'localhost'
  • options.mongoUri? <string> - Mongo URI. Default: process.env.MONGO_URI || 'mongodb://localhost:27017/zaife'
  • options.pathToResolvers <string> - Directory of resolver files
  • options.pathToTypes <string> - Directory of type (.gql) files
  • options.pathToModels <string> - Directory of mongoose model files

server.start()

Starts the server. An async function.

server.stop()

Stops the server. An async function.

Object: Zaife.Models

const ModelName = Models(modelName)

Access your mongoose models given the model name.

  • modelName <string> - Name of your mongoose model

Object: Zaife.Scalars

Access custom scalar types.

import { Scalars } from 'zaife';

const {
  GraphQLEmail,
  GraphQLURL,
  GraphQLDateTime,
  GraphQLLimitedString,
  GraphQLPassword,
  GraphQLUUID,
  GraphQLJSON,
} = Scalars;