rethinkdb / horizon

Horizon is a realtime, open-source backend for JavaScript apps.
MIT License
6.78k stars 351 forks source link

Make this README true #117

Closed deontologician closed 8 years ago

deontologician commented 8 years ago

Getting started with Horizon

First, install horizon from npm:

$ npm install -g horizon

Now you can initialize a new horizon project:

$ hz init example-app

This will create a directory with the following files:

$ tree -aF example-app/
example-app/
├── dist/
│   └── index.html
├── .hzconfig
└── src/

The dist directory is where you should output your static files. Horizon doesn't have any opinions about what front-end build system you use, just that the files to serve end up in dist. Your source files would go into src but that's just a convention. Horizon doesn't touch anything in src.

If you want, you can npm init or bower init in this directory to set up dependencies etc.

By default, horizon creates a basic index.html to serve so you can verify everything is working:

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8">
    <script src="/horizon/horizon.js'></script>
    <script>
      var horizon = Horizon();
      horizon.onConnected(function() {
        document.querySelector('h1').innerHTML = 'It works!'
      });
    </script>
  </head>
  <body>
   <marquee><h1></h1></marquee>
  </body>
</html>

Finally, let's start up a horizon server in dev mode. This will start a RethinkDB instance, connect to it, and serve our static files.

$ hz serve --dev
Starting RethinkDB ...
Admin UI available on port 8080
Driver connections should connect on 28015
Horizon is running and available at http://localhost:8181

Now you're cooking with fusionhorizon...

deontologician commented 8 years ago

I am going to try getting this working as best I can

dalanmiller commented 8 years ago

This is a really good idea, most importantly the marquee tag. I wonder though with the hz alias if people are going to starting calling us hertz instead of horizon.

deontologician commented 8 years ago

hzn ?

mlucy commented 8 years ago

I think hz is great.

marshall007 commented 8 years ago

@deontologician I would suggest using yeoman for all the generator stuff. If you publish a separate generator-horizon template to npm horizon init <app> could just shell out to yo horizon <app> or use yeoman programmatically.

This would scale out nicely if/when people (or you guys) write more framework-specific scaffolding templates. As an example horizon init <app> --framework=angular might (by convention) try to install and use generator-horizon-angular, which could either be a third-party or official generator.

Also, :+1: to hz!

deontologician commented 8 years ago

Do people still use yeoman?

marshall007 commented 8 years ago

@deontologician I thought it was still the go-to scaffolding framework. If there's some new hotness out there I haven't heard of it.

chrisvariety commented 8 years ago

@marshall007 https://github.com/slushjs/slush maybe

deontologician commented 8 years ago

I haven't heard of anything new, I just haven't heard anything about yeoman recently. I think for now, since we only need to generate a single file, I'm just putting it into a string literal. But later when we need to use adapters etc, it will probably make sense to integrate yeoman