Last active
August 29, 2015 14:17
-
-
Save PandaWhisperer/56e549ce8b65e05fd39a to your computer and use it in GitHub Desktop.
Demonstration for pandastrike/pbx#18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async = (require "when/generator").lift | |
{validate} = (require "pbx").filters | |
module.exports = -> | |
test: | |
create: validate async ({data}) -> | |
console.log yield data | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{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