Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/appup
CLI to launch apps that use an express main server and an optional restif api server.
https://github.com/thlorenz/appup
Last synced: 2 months ago
JSON representation
CLI to launch apps that use an express main server and an optional restif api server.
- Host: GitHub
- URL: https://github.com/thlorenz/appup
- Owner: thlorenz
- License: mit
- Created: 2013-08-08T15:54:23.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-28T21:07:03.000Z (over 10 years ago)
- Last Synced: 2024-04-15T03:08:14.281Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 792 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# appup [![build status](https://secure.travis-ci.org/thlorenz/appup.png?branch=master)](http://travis-ci.org/thlorenz/appup)
CLI to launch apps that use an express main server and an optional restif api server.
Servers are **super stable** with the help of [domains](http://nodejs.org/api/domain.html) and the [cluster module](http://nodejs.org/api/cluster.html).
This means in practice that **when a request causes an unhandled error a `500` response is sent, the server shut down**
**gracefully and a new one spun up**.Two servers are spun up originally for each port, so that **while one is restarted, the other one keeps servicing incoming requests**.
## Installation
npm install appup
## CLI
```
appup [options] fileOptions:
--pages port to start pages server on
--watchdir directory to watch for client side JavaScript changes in order to automatically refresh
--dedupe if set it will [dynamically dedupe] (https://github.com/thlorenz/dynamic-dedupe)
all modules as they are being required to work around the fact that symlinks break `npm dedupe`
--api port to start api server on
--apihost address at which api server is hosted [default: "localhost"]
--tunnel sets up local tunnel pointing to pages port and logs url to connect to from remote client
--config point to a config file to override routes, etc. for the pages and api server
--nocluster if set, single servers are launched instead of a cluster of them, which maybe preferred during development
```## API
appup(opts)Creates browserify bundle and starts up pages server and/or api server according to the supplied options.
If no api port is given, the api server is not started up.
If no pages port is given, the pages server is not started up.
If neither port is given, an error is thrown.Parameters:
Name
Type
Description
opts
Object
Properties
Name
Type
Argument
Description
pagesPort
number
<optional>
port at which to start up pages server
apiPort
number
<optional>
port at which to start up api server
apiHost
string
<optional>
specifies where api server is hosted (default: 'localhost')
config
string
full path configuration provided to override browserify specific options and/or custom API/Pages servers init functions
entry
string
entry file to add to browserify
watchdir
string
<optional>
turns on live reload for the given directory
dedupe
boolean
<optional>
turns on dynamic-dedupe
tunnel
boolean
<optional>
sets up local tunnel pointing to @see opts.pagesPort and logs url to connect to from remote client
nocluster
boolean
<optional>
(default:
false
) if set totrue
single servers are launched instead of a cluster of them*generated with [docme](https://github.com/thlorenz/docme)*
### config
The config needs to provide either or all of the following properties on the module exports object:
- **bundleOpts**: `{Object}` options passed to `browserify().bundle(options)`
- **initBrowserify**: `{Function}` invoked with `browserify` that needs to return a browserify *instance* that can be
initialized according to our needs
- **initPages** {Function} invoked with `(pagesApp, express, apiServerInfo)` where apiServerInfo is `{ host: {string}, port: {number} }`
- **postInitPages** {Function} invoked with `(pagesApp, pagesServer, express)` where `pagesServer` is the result of
`pagesApp.listen()`
- **pagesSend500** {Function} invoked with `(req, res, err)` to allow responding with a 500 error before worker gets taken
offline and another one is launched
- **initApi** {Function} invoked with `(apiApp, restify)`
- **postInitApi** {Function} invoked with `(apiApp, apiServer, restify)` where `apiServer` is the result of
`apiApp.listen()`
- **apiSend500** {Function} invoked with `(req, res, err)` to allow responding with a 500 error before worker gets taken
offline and another one is launched
- **events** {EventEmitter} used to emit `info` and `error` events, if not provided messages are logged to the console
instead#### Example config
```js
// Bundle options
exports.bundleOpts = { debug: true, insertGlobals: false };exports.initBrowserify = function (browserify) {
return browserify().transform('hbsfy');
};// Server options
// Pages
exports.initPages = function (pagesApp, express, apiServerInfo) {
pagesApp.use(core.renderViewMiddleware(viewPath, { title: 'core' }));
};exports.postInitPages = function (pagesApp, pagesServer, express) {
};// API
exports.initApi = function (apiApp, restify) {
};exports.postInitApi = function (apiApp, apiServer, restify) {
};
```## License
MIT