Angular Stassets Servers
A collection of base servers for angular and stassets projects.
Use this package to create and configure an Express server that manages static files and configures API endpoints.
Example Usage
Add some configuration options to package.json
.
package.json
Set the global.root
to understand file paths, pass package.json
to the
ng-stassets
server of your choice, and call start
on the server reference
you get back.
app.js
globalroot = __dirname;start
By default, stassets
looks for a component-based project architecture,
compiling Jade, Coffee, Javascript, Stylus, and CSS. See [stassets][stas]
for
more details.
src/client/index.jade
doctypehtml head title Hello, ng-stassets-test! body h1 Hi there!
Define API routes. Any files matching the pattern in the routing
URL will be
require
d, expecting a function that takes a reference to an Express app
and
the config
passed to the root ng-stassets
load, in this case the entire
package.json
.
src/server/hello/route.coffee
debug = require'debug''ng-stassets-test:help'= appget '/hello' ssend "Hello from " debug 'Attaching /hello'
Recognized Options
These options can be passed as an object to ng-stassets
, though best practice
for servers is to place them in package.json
.
name
Required. The name for the app.
hostname
Optional. The hostname to server on. Will use HOST
from the environment, or
os.hostname()
as a default.
port
Optional. Integer port to listen on. Defaults to 8080.
stassets
Optional. A configuration for the underlying stassets
compiler. If false
,
completely disables stassets
. For more information, see the stassets
docs.
stassets.root
Required. The root directory for stassets
client files, relative to
global.root
specified in the root js file. If an array, specifies the root
directories for a cascading file system.
stassets.framework
Optional. One of "none"
, "ionic"
, or "bootstrap"
. "none"
loads vanilla
Angular. "ionic"
loads Angular with Ionic styles, components, and themes.
"bootstrap"
does the same. In fact, this preconfigures the vendors
key.
Defaults to "ionic"
.
stassets.vendors
Optional. Additional vendor root directories and files.
routing
Optional. Array of glob paths. Any file matching that glob will be loaded and
called as a function taking app
, a reference to the application server, and
config
, a reference to this configuration object.
tls
Optional. If present, will configure the server to use SSL encryption for all
connections. If true
, will load TLS using default values.
tls.port
Optional. Port for HTTPS to listen on. Defaults to 8443.
tls.key
Optional. Path to server private key. Defaults to
"#{global.root}/env/server.key"
.
tls.cert
Optional. Path to server public certificate. Defaults to
"#{global.root}/env/server.crt"
.
Changelog
- 0.0.14 20214-09-26 Bin script to generate cert. Env overrides config.
- 0.0.13 2014-09-17 Loads hostname from platform or config.
- 0.0.0 - 0.0.11 2014-09-11 Initial work; lots of iterative tweaks.
Roadmap
- Hapi.js integration. Allow choosing Hapi or Express frameworks.