{"__v":17,"_id":"54d5635732d98b0d00384b13","category":{"__v":19,"_id":"54d5635632d98b0d00384afe","pages":["54d5635732d98b0d00384b12","54d5635732d98b0d00384b13","54d5635732d98b0d00384b14","54d847c125e90a0d00db551f","54d995416a09052100a6b6d7","54d995534c49f40d00dff98a","54d9956b4c49f40d00dff98c","54dbce210e553a0d00dc1d09","54dcdf7bac05560d00335a15","54dd133c08f6b61700a691f7","54dd136108f6b61700a691fa","54dd27e0db3b362100131294","54dd2838ca1e5219007e9dcb","54dd28c8db3b362100131296","54deb1133a91410d001b1791","54deb134c4a3570d009d4a60","54dec5c0c2b4b70d009c3f05","54ded495e8e35a0d007551a0","54ded57d8e7b000d007c7f31","551447a90edb420d0050016e","551c4369ff892b3700d1c616"],"project":"54d53c7b23010a0d001aca0c","version":"54d5635532d98b0d00384afb","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-06T23:44:18.708Z","from_sync":false,"order":4,"slug":"api-plugins","title":"API Plugins"},"parentDoc":null,"project":"54d53c7b23010a0d001aca0c","user":"54cfa8e1a8a4fd0d00b7fd1d","version":{"__v":10,"_id":"54d5635532d98b0d00384afb","forked_from":"54d53c7c23010a0d001aca0f","project":"54d53c7b23010a0d001aca0c","createdAt":"2015-02-07T00:59:01.934Z","releaseDate":"2015-02-07T00:59:01.934Z","categories":["54d5635632d98b0d00384afc","54d5635632d98b0d00384afd","54d5635632d98b0d00384afe","54d5635632d98b0d00384aff","54d5635632d98b0d00384b00","54d5635632d98b0d00384b01","54d5635632d98b0d00384b02","54d652097e05890d006f153e","54dd1315ca1e5219007e9daa","54e21e2b22de1c230094b147","54e68e62a43fe13500db3879","54fa1d3fe7a0ba2f00306309","551c453a23a1ee190034d19a","551df586e52a0b23000c62b6","551f39be6886f8230055f02a","55a6720751457325000e4d97"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.1.0","version":"0.1"},"updates":["5508b276775d2c1700db0a39"],"next":{"pages":[],"description":""},"createdAt":"2015-02-06T23:45:39.879Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"Cloud9 is build on top of Node.js on the server. We experienced the benefits of using the same language on the server and on the client. After learning from the 1st and 2nd version of Cloud9, we decided to make our plugins *client side* only. After we got really used to the asynchronous programming style that Node.js offers we decided to base our *client side plugins* [fs, proc and net](doc:working-with-fs-proc-and-net-apis) on the Node's apis. \n\nMany of the Node.js modules could be very useful when writing Cloud9 plugins. As mentioned the Cloud9 plugins are *client side* only and so we did the extra work of making them available for you in the browser, to use in your plugins. One of these modules is the `path` module that allows you to easily manipulate paths. The next example shows how to use these modules in your plugin:\n\n```\nvar join = require(\"path\").join;\nvar basename = require(\"path\").basename;\n\nvar filename = basename(\"/home/ubuntu/test.js\");\nvar newPath = join(\"/var/lib\", filename);\n```\n\nThese are all the Node.js modules that we support and their use case.\n[block:html]\n{\n  \"html\": \"<table>\\n  <tr><th>Module</th><th>Description</th></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/assert.html\\\" target=\\\"_blank\\\">assert</a></td><td>This module is used for writing unit tests for your applications.</td></tr>\\n  <tr><td><a href=\\\"https://github.com/caolan/async\\\" target=\\\"_blank\\\">async</a></td><td></td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/events.html\\\" target=\\\"_blank\\\">events</a></td><td></td></tr>\\n  <tr><td>http-error</td><td></td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/http.html\\\" target=\\\"_blank\\\">http</a></td><td></td></tr>\\n  <tr><td><a href=\\\"https://lodash.com/\\\" target=\\\"_blank\\\">lodash</a></td><td></td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/path.html\\\" target=\\\"_blank\\\">path</a></td><td>This module contains utilities for handling and transforming file paths</td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/querystring.html\\\" target=\\\"_blank\\\">querystring</a></td><td>This module provides utilities for dealing with query strings.</td></tr>\\n  <tr><td><a href=\\\"http://sinonjs.org/\\\" target=\\\"_blank\\\">sinon</a></td><td></td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/stream.html\\\" target=\\\"_blank\\\">stream</a></td><td>A stream is an abstract interface implemented by various objects in Node.</td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/url.html\\\" target=\\\"_blank\\\">url</a></td><td>This module has utilities for URL resolution and parsing.</td></tr>\\n  <tr><td><a href=\\\"http://nodejs.org/api/util.html\\\" target=\\\"_blank\\\">util</a></td><td></td></tr>\\n  <tr><td><a href=\\\"http://einaros.github.io/ws/\\\" target=\\\"_blank\\\">ws</a></td><td>A simple interface for web socket usage</td></tr>\\n</table>\"\n}\n[/block]","excerpt":"","slug":"using-common-nodejs-apis","type":"basic","title":"Common Node.js APIs"}

Common Node.js APIs


Cloud9 is build on top of Node.js on the server. We experienced the benefits of using the same language on the server and on the client. After learning from the 1st and 2nd version of Cloud9, we decided to make our plugins *client side* only. After we got really used to the asynchronous programming style that Node.js offers we decided to base our *client side plugins* [fs, proc and net](doc:working-with-fs-proc-and-net-apis) on the Node's apis. Many of the Node.js modules could be very useful when writing Cloud9 plugins. As mentioned the Cloud9 plugins are *client side* only and so we did the extra work of making them available for you in the browser, to use in your plugins. One of these modules is the `path` module that allows you to easily manipulate paths. The next example shows how to use these modules in your plugin: ``` var join = require("path").join; var basename = require("path").basename; var filename = basename("/home/ubuntu/test.js"); var newPath = join("/var/lib", filename); ``` These are all the Node.js modules that we support and their use case. [block:html] { "html": "<table>\n <tr><th>Module</th><th>Description</th></tr>\n <tr><td><a href=\"http://nodejs.org/api/assert.html\" target=\"_blank\">assert</a></td><td>This module is used for writing unit tests for your applications.</td></tr>\n <tr><td><a href=\"https://github.com/caolan/async\" target=\"_blank\">async</a></td><td></td></tr>\n <tr><td><a href=\"http://nodejs.org/api/events.html\" target=\"_blank\">events</a></td><td></td></tr>\n <tr><td>http-error</td><td></td></tr>\n <tr><td><a href=\"http://nodejs.org/api/http.html\" target=\"_blank\">http</a></td><td></td></tr>\n <tr><td><a href=\"https://lodash.com/\" target=\"_blank\">lodash</a></td><td></td></tr>\n <tr><td><a href=\"http://nodejs.org/api/path.html\" target=\"_blank\">path</a></td><td>This module contains utilities for handling and transforming file paths</td></tr>\n <tr><td><a href=\"http://nodejs.org/api/querystring.html\" target=\"_blank\">querystring</a></td><td>This module provides utilities for dealing with query strings.</td></tr>\n <tr><td><a href=\"http://sinonjs.org/\" target=\"_blank\">sinon</a></td><td></td></tr>\n <tr><td><a href=\"http://nodejs.org/api/stream.html\" target=\"_blank\">stream</a></td><td>A stream is an abstract interface implemented by various objects in Node.</td></tr>\n <tr><td><a href=\"http://nodejs.org/api/url.html\" target=\"_blank\">url</a></td><td>This module has utilities for URL resolution and parsing.</td></tr>\n <tr><td><a href=\"http://nodejs.org/api/util.html\" target=\"_blank\">util</a></td><td></td></tr>\n <tr><td><a href=\"http://einaros.github.io/ws/\" target=\"_blank\">ws</a></td><td>A simple interface for web socket usage</td></tr>\n</table>" } [/block]