Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
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
//Enter in the url or file path of module dependencies. ng will load them first
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)
{
//ng is a listener that accepts a request & reponse
require('http').createServer(ng).listen(1337)
//Just like most node.js frameworks ng uses a stack of middleware
//however its middleware uses Angular's interceptor API. Valid
//properties include request, requestError, response, responseError
//The example below sends an app's base template if the response has no data
ng.stack(function()
{
return {
response:function(data)
{
//ng.toString() will concatenate all modules, replacing
//the need to specify each one manually. To do it the
//manual way replace ng with the three lines below:
//'<script>'+ng.module('ng')+'</script>',
//'<script>'+ng.module('ngRoute')+'</script>',
//'<script>'+ng.module('example')+'</script>',
return data ||
[
"<html ng-app='example'>",
"<head>",
ng,
"</head>",
"<body>",
"<div class='ng-view'></div>",
"</body>",
"</html>"
]
.join('\n')
}
}
})
//Now we are done with ng specifics, the rest of our app looks
//almost exactly like angular!!! Look carefully to spot some
//nodejs specific functions like require/readFile/__dirname etc.
.module('example', ['ngRoute'])
//Because it has a require, this factory will be placed the server.
//If you access from the client - e.g., in a controller - then ng
//will send an http request run the function on the server and
//return the result, so it will look like it was run on the client
.factory('$os', function($http, $cpus)
{
var os = require('os')
return [os.cpus, os.cpus]
})
//This factory will be put on server and client
//it will be run from whereever it is accessed
.factory('me', function(us) { return 'hi' })
//Easily import 3rd party code such as a db factory/directive
.factory('db', require('ng.cql').factory)
.directive('db', require('ng.cql').directive)
//Controllers are automatically put on the client
.controller('base', function($scope, $os, $cpus, $http, db)
{
$scope.test = db('test').select('*')
$scope.os = $os[1]()
$scope.version = ng.version
})
//Configs/runs are put on client and server. We make an exception
//for templates, where the template parser will run the template
//on the server (readFileSync in this case) and push that result
//to the client config. All config/runs are put on client as-is
.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);
})
//OPTIONAL ADVANCED USAGE
//Internally ng pre-processes your module code, this functionality
//is added to the public api as ng.parse(), allowing cool things like
//automatically creating angularjs's inline injection array,
//or making your code pretty with automatic indentation.
//Include these stock parsers by specifying 'inline' and/or 'whitespace'
ng.parse('inline').parse('whitespace')
//Make your own custom parsers using the function signature below
//For more example's look at the stock parsers in parser.js
//.parse.client() and .parse.server() provide more granularity
.parse(function(fn, type, name)
{
//Uncomment lines below to see how a custom parser works
//console.log('I am parsing', type, name)
//console.log('Function to parse & return', fn.toString())
//console.log('Module API available as this', this)
return fn //I didn't do anything, kept function as-is
})
})
##todos
##related projects
FAQs
Unknown package
We found that ng demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.