Skip to content

Instantly share code, notes, and snippets.

@PandaWhisperer
Last active August 29, 2015 14:17
Show Gist options
  • Save PandaWhisperer/56e549ce8b65e05fd39a to your computer and use it in GitHub Desktop.
Save PandaWhisperer/56e549ce8b65e05fd39a to your computer and use it in GitHub Desktop.
Demonstration for pandastrike/pbx#18
{Builder} = require "pbx"
builder = new Builder "mediatype"
builder.define "test"
.post as: "create", creates: "test", type: "application/json"
.schema
required: ["title"]
properties:
title: type: "string"
description: type: "string"
builder.reflect()
module.exports = builder.api
async = (require "when/generator").lift
{validate} = (require "pbx").filters
module.exports = ->
test:
create: validate async ({data}) ->
console.log yield data
{call} = require "when/generator"
{processor} = require "pbx"
initialize = require "./handlers"
api = require "./api"
api.base_url = "http://localhost:8080"
call ->
(require "http")
.createServer yield (processor api, initialize)
.listen 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment