{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"Quick Start","type":"basic","slug":"quick-start","excerpt":"This page will help you install Lever OS and show you how to write your first Lever service!","body":"# Prerequisites\n\n* [Docker](https://docs.docker.com/engine/installation/) 1.11+ and [Docker Compose](https://docs.docker.com/compose/install/) 1.7+. On a Mac you can install [Docker Toolbox](https://docs.docker.com/toolbox/overview/) to get what you need.\n* Make\n* Linux or Mac (Windows should work too but it was never tested)\n\nIf you need to use docker-machine to run docker (eg on a Mac), you also need to install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and then run these commands to [get started](https://docs.docker.com/machine/get-started/):\n\n```\n$ docker-machine create --driver virtualbox default\n$ eval `docker-machine env default`\n```\n\nYou will need to run the second command for every new terminal window.\n\n# Installation\n\n```bash\n$ git clone https://github.com/leveros/leveros\n$ cd leveros\n$ make\n$ sudo make install-cli\n$ make fastrun\n```\n\nThe commands above pull the necessary Docker images, install the `lever` CLI and run a Lever OS instance locally.\n\n# Your first Lever service\n\n```bash\n$ mkdir hello\n$ cd hello\n```\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"module.exports.sayHello = function (name, callback) {\\n callback(null, \\\"Hello, \\\" + name + \\\"!\\\");\\n};\",\n \"language\": \"javascript\",\n \"name\": \"server.js\"\n }\n ]\n}\n[/block]\n\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"{\\n \\\"name\\\": \\\"helloService\\\",\\n \\\"description\\\": \\\"A hello service.\\\",\\n \\\"jsEntry\\\": \\\"server.js\\\"\\n}\",\n \"language\": \"json\",\n \"name\": \"lever.json\"\n }\n ]\n}\n[/block]\n### Deploy your service locally\n\n```bash\n$ lever deploy\n```\n\nThis takes the whole current directory, archives it and deploys it onto Lever in `dev.lever`, the default environment.\n\n### Invoke via CLI\n\n```bash\n$ lever invoke lever://dev.lever/helloService/sayHello '\"world\"'\n\n\"Hello, world!\"\n\n# Or even shorter (only for dev.lever)...\n$ lever invoke /helloService/sayHello '\"world\"'\n\n\"Hello, world!\"\n```\n\nRemember to use proper JSON for arguments. This includes the quotes for strings.\n\n### Invoke via HTTP POST request\n\n```bash\n# Without docker-machine\n$ curl -H \"Content-Type: application/json\" -X POST -d '[\"world\"]' \\\nhttp://127.0.0.1:8080/helloService/sayHello?forceenv=dev.lever\n\n\"Hello, world!\"\n\n# With docher-machine\n$ curl -H \"Content-Type: application/json\" -X POST -d '[\"world\"]' \\\nhttp://$(docker-machine ip default):8080/helloService/sayHello?forceenv=dev.lever\n\n\"Hello, world!\"\n```\n\nNotice the `forceenv` query param at the end of the command. This is a convenience feature that allows you to access Lever's HTTP API without having `dev.lever` assigned to the listening IP (and also configuring Lever to serve on port `80`).\n\n### Invoke from browser (via HTTP API)\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"$.ajax({\\n 'type': 'POST',\\n 'url': 'http://127.0.0.1:8080/helloService/sayHello?forceenv=dev.lever',\\n 'contentType': 'application/json',\\n 'data': JSON.stringify([\\\"world\\\"]),\\n 'dataType': 'json',\\n 'success': function (data) {\\n console.log(data); // Hello, world!\\n },\\n});\",\n \"language\": \"javascript\",\n \"name\": \"browser.js\"\n }\n ]\n}\n[/block]\nNote that when using docker-machine, you need to replace `127.0.0.1` with the output of the command `docker-machine ip default`.\n\n### Invoke from Node\n\n```bash\n$ npm install leveros\n```\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"var leveros = require('leveros');\\n\\nvar client = new leveros.Client();\\nclient.forceHost = process.env.LEVEROS_IP_PORT;\\nvar service = client.service('dev.lever', 'helloService');\\nservice.invoke('sayHello', \\\"world\\\", function (error, reply) {\\n console.log(reply); // Hello, world!\\n});\",\n \"language\": \"javascript\",\n \"name\": \"client.js\"\n }\n ]\n}\n[/block]\n```bash\n# Without docker-machine\n$ LEVEROS_IP_PORT=\"127.0.0.1:8080\" node client.js\n\n# With docher-machine\n$ LEVEROS_IP_PORT=\"$(docker-machine ip default):8080\" node client.js\n```\n\nSetting LEVEROS_IP_PORT is necessary so that you can invoke the `dev.lever` environment without adding an entry for it in `/etc/hosts` and setting the listen port to `80`.\n[block:api-header]\n{\n \"type\": \"basic\",\n \"title\": \"What's next?\"\n}\n[/block]\nNow that you have your first Lever service up and running, learn more about what you can do with Lever by taking a look at the [Concepts](doc:basic-concepts) page.\n\nLater, you might also want to check out the API reference pages. See links on left-hand side.","updates":[],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"57241f832887bb0e00bb9da8","user":"5723ea8efda3c70e005b88e3","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Documentation","slug":"documentation","order":0,"from_sync":false,"reference":false,"_id":"5723eaebeae5090e00ee61f2","createdAt":"2016-04-29T23:14:24.983Z","version":"5723eaebeae5090e00ee61f1","project":"5723ead0fda3c70e005b88e5","__v":0},"githubsync":"","parentDoc":null,"project":"5723ead0fda3c70e005b88e5","version":{"version":"0.1","version_clean":"0.1.0","codename":"","is_stable":true,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["5723eaebeae5090e00ee61f2","5723f854110e570e00486c7a","572a28f6d10a200e00b1cb14"],"_id":"5723eaebeae5090e00ee61f1","createdAt":"2016-04-29T23:14:51.190Z","releaseDate":"2016-04-29T23:14:51.190Z","__v":3,"project":"5723ead0fda3c70e005b88e5"},"__v":18,"createdAt":"2016-04-30T02:59:15.770Z"}
Quick Start
This page will help you install Lever OS and show you how to write your first Lever service!