# Nephos Ruby Server [![Gem Version](https://badge.fury.io/rb/nephos-server.svg)](http://badge.fury.io/rb/nephos-server) This is a minimal web server, based on [rack](https://github.com/rack/rack) and [puma](https://github.com/puma/puma). It is written in ruby. It also gives you a minimal architecture to speed up your application bootstrap. Features provided: - Controllers: gives you a resource logic. - Render: easier render content to the client. - Router: create a robust and simple routing system, with url variables. Features which will not be provided by nserver: - Templating (HTML with variables, loops, ...): It already exists and it is easy to implement. - [Slim](DOCUMENTATION/TEMPLATING/SLIM.md) - Database orm and connector: It already exists and simple to implement too. - [Sequel](DOCUMENTATION/DATABASE/SEQUEL.md) # Start ```sh gem install nephos # download the server and executables ngenerator application MyApp # generate the application cd MyApp # go in nserver -p 8080 -h 0.0.0.0 # start the server. port is not required, neither host ``` ``nserver`` is an executable designed to start the server easly. It can take few arguments, all optionnal: - ``-p``: port to listen - ``-h``: host to listen (network address) - ``-e``: environment (default is development, can be set to production) - ``-d``: daemonize the process - ``-k``: kill daemonized process # Documentation ## Guides Theses guides will provide you knowlegde about everything you can use in the application. - [Generator GUIDE](DOCUMENTATION/GUIDE_GENERATOR.md) - [Render API](DOCUMENTATION/API_RENDER.md) - [Router GUIDE](DOCUMENTATION/GUIDE_ROUTER.md) - [Controller GUIDE](DOCUMENTATION/GUIDE_CONTROLLER.md) - [Code documentation on RubyDoc.info](http://www.rubydoc.info/gems/nephos-server/toplevel) -> **Note: you can also generate local documentation via yard** ## Examples ### Production To avoid information leaks from your application, set the environment variable ``export ENVIRONMENT=production``, or run the server with ``-e production`` parameter. It will disable ruby error messages when an error occurs in the controller. ### Controller To create a controller, add a ruby file to ``app/``, with a class inherited by ``Nephos::Controller`` The basic code of a controller can be generated via ``ngenerator controller NAME``. ```ruby class Example < Nephos::Controller def root cookies["last_visit"] = Time.now if params["index"] == "true" return {plain: "index"} else return :empty end end end ``` ### Rendering To render a content to the client, you can return informations from a Controller method: ```ruby return 404 return {status: code} return {status: code, content: "Not today"} return {json: {status: "resource created"}, status: 201} return {plain: "text"} return {html: "