Giter VIP home page Giter VIP logo

carbond's Introduction

Carbon.io

Travis build status npm Version npm downloads supported node versions MIT License

Carbon.io is an application framework based on Node.js and MongoDB for building command line programs, microservices, and APIs.

With Carbon.io you can create simple, database-centric microservices with virtually no code. At the same time Carbon.io is designed to let you under the hood and allows you to write highly customized APIs much like you would with lower-level libraries such as Express.js.

Quickstart

To install:

$ npm install carbon-io

Copy the following code into service.js:

var carbon = require('carbon-io')

var o  = carbon.atom.o(module).main
var __ = carbon.fibers.__(module)

__(function() {
  module.exports = o({
    _type: carbon.carbond.Service,
    port: 8888,
    endpoints: {
      hello: o({
        _type: carbon.carbond.Endpoint,
        get: function(req) {
          return { msg: "Hello world!" }
        }
      })
    }
  })
})

This will create a Carbon.io service which will respond with "Hello world!" on the /hello endpoint. Run the service with:

$ node service

And test it using:

$ curl localhost:8888/hello

Documentation

Interested in getting started with Carbon.io? Check out our detailed documentation on the Carbon.io website.

Contributing

Interested in contributing to Carbon.io? We love to receive new contributions! There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code which can be incorporated into Carbon.io itself.

Check out our CONTRIBUTING.md for tips on how to get started!

License

MIT License

carbond's People

Contributors

agjohnson avatar alek-mongodb avatar benelgar avatar chrisckchang avatar gregbanks avatar hexagon-io avatar nir-jacobson avatar tfogo avatar willshulman avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

carbond's Issues

Should be able to return undefined from Operation

Right now we can't return undefined from an operation. It causes a hang given the way we detect sync vs async in ObjectServer.js. Is there a way to tell if the response has been written to that could help us change the logic around some?

how is `Operation.errorResponses` supposed to look?

  _C: function() {
    this.parameters = {}
    this._allParameters = null // cache of all parameters including inherited parameters
    this.responseSchema = undefined
    this.errorResponses = undefined
    this.objectserver = null
    this.endpoint = null
  },

ObjectServer.middleware

Something like

{
middleware: [
function(req, res, next) {},
function(req, res, next) {},
...
]
}

decide on node cluster options and behavior

node cluster support is enabled when passing the --cluster flag. the number of worker processes started defaults to the number of CPUs present and is configurable with the --num-cluster-workers option.

what other options do we need? do we want the master to automatically restart workers? do we want to have a command line flag to control this?

Invalid JSON breaks body parser

Invalid json sent in body fails body parser in non-friendly way.

Should be able to get message out to client but we get this. Should re-test on latest Node.js

SyntaxError: Unexpected string
at Object.parse (native)
at parse (/Users/will/src/github/carbon-io/carbond/node_modules/body-parser/lib/types/json.js:84:17)
at /Users/will/src/github/carbon-io/carbond/node_modules/body-parser/lib/read.js:102:18
at IncomingMessage.onEnd (/Users/will/src/github/carbon-io/carbond/node_modules/body-parser/node_modules/raw-body/index.js:149:7)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)

MongoDBCollection find parameters not working

When using a _type: MongoDBCollection, parameters "sort", "field", "skip", and "limit" do not seem to get sent along with the query from the objectserver:

URL (GET) sent to carbon server and resulting log line (no ntoreturn, returns all documents with {"published": true}):

http://localhost:8885/events?query={"published":true}&limit=1

2016-06-02T15:41:18.140-0700 I COMMAND [conn386] command mongolab-status.public-status-events command: find { find: "public-status-events", filter: { published: true }, projection: {} } planSummary: COLLSCAN keysExamined:0 docsExamined:3 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:0 nreturned:2 reslen:758 locks:{ Global: { acquireCount: { r: 2 } }, MMAPV1Journal: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } } } protocol:op_query 0ms

shell command and resulting log line (ntoreturn is 1, returns 1 document):

db['public-status-events'].find().limit(1)

2016-06-02T14:41:06.736-0700 I QUERY [conn392] query mongolab-status.public-status-events planSummary: COLLSCAN ntoreturn:1 ntoskip:0 keysExamined:0 docsExamined:1 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:0 nreturned:1 reslen:395 locks:{ Global: { acquireCount: { r: 2 } }, MMAPV1Journal: { acquireCount: { r: 1 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { R: 1 } } } 0ms

Calling find() against Collection without .toArray() gives cryptic error

When omitting .toArray() from a find() call against a carbon.carbond.collections.Collection, the error is the following:

[Fri Jun 03 2016 11:30:44 GMT-0700 (PDT)] ERROR: TypeError: Converting circular structure to JSON
at Object.stringify (native)

appears to come from JSON.stringify()

OperationParameter.resolver

Do we support this? If so need have a way to get at both the parameter and the raw value. Otherwise we should remove from code til we are ready to support.

Views need work

Probably should be on Operation. Might not be right as they are with Collection given the flexibility of responses in Collections.

Advanced collection tests

  • Tests all different configuration options, particularly for operation configs
  • Tests custom idPathParameter

What types of JSON serialization do we support in params?

Request qs and querystring cause JSON query params to come out very
strange (to me :). Why do we need a new JSON syntax?

What we support -- what is configurable? Right now I think if we stringfy json on carbon client the server can support our style and what request puts out.

There is also security to consider. Certain serialization forms may have security implications.
i.e. de-support un-packed array syntax? We want to look carefully at JSON injection and how one can make objects without realizing it.

We also want to watch for method spoofing on Endpoint classes (must protect against invoking class methods that are not HTTP verbs -- should have unit test for this).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.