Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cass

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cass

It rhymes with jax-rs

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Cass

It rhymes with jax-rs.

A convenience layer to build JSON APIs using Quinn.

const cass = require('cass'),
      // `boom` is whitelisted for providing status codes
      Boom = require('boom');

const handler = cass(req => {
  if (req.method !== 'GET') throw Boom.create(405);

  return {
    my: {
      response: { entity: true }
    }
  };
});

// handler can be passed into quinn's createApp

In combination with Wegweiser:

import { createServer } from 'http';

import cass from 'cass';
import { createRouter, GET, PUT } from 'wegweiser';
import parsedBody from 'parsed-body';
import { createApp } from 'quinn';

import db from './db'; // e.g. require('knex')(options)

const todos = db('todos');

const routes = [
  GET('/todos')(req => todos.select()),
  GET('/todos/:id')((req, id) => todos.first().where({ id })),
  PUT('/todos/:id')(async (req, id) => {
    const { done } = await parsedBody(req);
    if (0 === await todos.where({ id }).update({ done })) {
      return; // item not found
    }
    return todos.first().where({ id });
  })
];

// routes -> router
// router -> JSON responses
// JSON responses -> node style request listener
// node style request listener -> node http server
createServer(createApp(cass(createRouter(routes))))
  .listen(3000);

Keywords

FAQs

Package last updated on 20 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc