ng: full-stack angular (warning! pre-alpha)
With node.js came full-stack javascript. However, developers still had to use
different frameworks to build frontend apps and their backend apis. Enter ng,
now there is an elegant, full-stack AngularJS framework with no other dependencies
While still in pre-alpha, ng is being built for production environments with sponsorship
by Pook-n-Cheek. If you are interested in contributing to the project, email adam at adam.kircher@gmail.com
Example
var modules =
{
ng:'//ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js',
ngRoute:'node_modules/ng.cdn/1.2.0-route.js'
}
require('ng')(modules, function(ng)
{
require('http').createServer(ng).listen(1337)
ng.stack(function()
{
return {
response:function(data)
{
return data ||
[
"<html ng-app='example'>",
"<head>",
ng,
"</head>",
"<body>",
"<div class='ng-view'></div>",
"</body>",
"</html>"
]
.join('\n')
}
}
})
.module('example', ['ngRoute'])
.factory('$os', function($http, $cpus)
{
var os = require('os')
return [os.cpus, os.cpus]
})
.factory('me', function(us) { return 'hi' })
.factory('db', require('ng.cql').factory)
.directive('db', require('ng.cql').directive)
.controller('base', function($scope, $os, $cpus, $http, db)
{
$scope.test = db('test').select('*')
$scope.os = $os[1]()
$scope.version = ng.version
})
.config(function($routeProvider, $locationProvider)
{
$routeProvider
.when('/george', {
template: require('fs').readFileSync('view/george.html'),
controller: 'base'
})
.when('/adam',
{
template:require('fs').readFileSync('view/adam.html'),
controller: 'base'
})
$locationProvider.html5Mode(true);
})
ng.parse('inline').parse('whitespace')
.parse(function(fn, type, name)
{
return fn
})
})
##Todos
- Many, many ideas. Feel free to email me suggestions!
- More stock middleware, gzip etc
- More stock parsers
- Testing API
- Make namespace use self-executing function rather than setting a global var
##Related Projects
- ng.seed: start a new ng project, get ENV options, creates index.js with example.
- ng.mod: directory based module loading for ng...
- ng.cql: realtime cassandra database syncronization without needing forms