Notes on setup. I use Ubuntu 12.04 for my dev machine.
$ sudo apt-get update
$ sudo apt-get install openssh-server
$ sudo apt-get install python-software-properties
$ sudo apt-get install wget curl vim git-core
$ sudo apt-get install build-essential
$ wget https://nodejs.org/dist/v0.9.9/node-v0.9.9.tar.gz
$ tar -xvf node-v0.9.9.tar.gz
$ cd node-v0.9.9
$ ./configure
$ make # Get some coffee
$ sudo make install
$ git clone [email protected]:newhavenio/newhavenio-website.git
$ cd newhavenio-website
$ vim package.json
> "version": "0.1.0" # from "version": "0.0.0"
> "node": ">=0.8.0 <0.10.*" # from "node": ">=0.8.0"
$ sudo npm install -g express # Install globally
$ express --sessions --ejs # Create express in local directory
$ npm install # Get dependencies
$ node app # Express server listening on port 3000
$ sudo npm install -g grunt-cli
$ sudo npm install -g bower
On a headless virtual machine, you can get grunt-server working with the --force
flag to keep it working despite live-reload not having a browser to open:
$ grunt server --force
Finally, there is both bower and npm package managers in play. Make sure all local dependencies are installed:
$ npm install
$ bower install
I believe you can follow the installation instructions for the static nhv.io website. Then, do this additional step to ensure express is installed globally.
npm install express
(We should probably be installing Bower globally too.)
Here's where stuff lives
app
= the client side applicationdist
= where the compiled, minified client side assets are putserver
= the server side applictiontest
= tests, both server and client, of which, few
The client side is an AngularJS application that talks to an Express application on the server. The server
- serves all the static content;
- has a RESTful API for managing users and companies; and
- uses GitHub for authentication via OAuth.
The client
- is defined in the static js & html content returned by the server;
- loads a bunch of stuff dynamically, including
- Meetup.com events, via JSONP; and,
- Users (developers) and companies via our server's RESTful API.
- allows CRUD on users and companies using Restangular, which is a nice way to interact with RESTful APIs from Angular applications.
GET /auth
- Will redirect you to Github for auth and redirect you to:
GET /auth/callback
- Which will then redirect you to GET /
When you load up the index page, and you're not logged in, there is
a "login with github" button at the bottom. After you've logged
in, there is an "edit profile" button, which takes you to a URL that
looks like https://localhost:9000/#/developers/5267ec3d505715ec75000001/edit
where the weird string of numbers is the primary key in your mongodb
database for that user. That controller uses Restangular to speak
to the backend and alter user data. The user list view is at
https://localhost:9000/#/developers
.
(The server is using in-memory sessions storage, which is fast, but of course we lose them every time the server is restarted.)
We're using Mongodb for the datastore and the office node ORM: Mongoose. The development environment requires you to start an instance of Mongodb locally to which you have write access. (See "Environment variables", below).
There are a handful of variables declared in the env
section of
Gruntfile.js
. However, most environment variables should be stored
in your .env
file so that you can run grunt
commands using
foreman
(or honcho or any other foreman clone). My .env
has the following
variables.
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
GITHUB_CALLBACK_URL=...
MONGOHQ_URL=...
COOKIE_SECRET=...
Note that, when you're developing locally, you won't need the AWS variables. You will, however, need to create an app for testing GitHub authentication. I suggest you make this under your own account, it's easy here.
You can set your own COOKIE_SECRET willy nilly locally and MONGOHQ_URL
should look something like mongodb:https://localhost/newhaven-io
locally
for development. I just run mongod
from the command line with no
arguments.
- Auth - Allow anyone to auth and add company? (Users separate from companies, separate from future user profiles?)
- Filter for authenticated actions (api requests need authentication)
- API - handle CRUD of business entries
- Design - Need Login with Github button or other call to action to add business to site