A simple development server for DoneJS projects.
npm install done-serve
node_modules/.bin/done-serve [path] [options]
[path]
is the root directory. Defaults to the current working directory.
To start a full server that hosts your application from the ./dist
directory on port 3030
run:
node_modules/.bin/done-serve dist --port 3030
The following [options]
can be specified from the command line:
Specify the port the server should run on. If unspecified this port will be one of:
- the
PORT
environment variable 3030
Proxy a local path (default: /api
) to the given URL (e.g. http://api.myapp.com
).
Set the proxy endpoint (default: /api
).
Turn off SSL certificate verification.
Start a live-reload server so any code changes will be reflected immediately.
Disable live-reload when used with the --develop
option.
Specify the port (a Number
) to use for live-reload. The default port is specified in the LiveReloadOptions documentation.
Only serve static files, do not perform server-side rendering. Notably this is useful when debugging an issue in the app.
With the --static
flag set, set an HTML page that should be sent instead of the normal error page. This is useful when you want to use Pushstate without server side rendering.
Specifies the name of a cookie that done-ssr will use to enable JavaScript Web Token (JWT) auth.
A comma-separated string of domain names that are authorized to receive the JWT token. Required if --auth-cookie
is used.
Specify a timeout for server rendering. If the timeout is exceeded the server will return whatever has been rendered up until that point. (default: 5000
)
Enable debug information in case of a timeout. The debug information will be appended to the document as a modal window and provides stack traces. Only use this flag during development.
Provide SSL key and certificate files. When providing these options both HTTP and HTTP2 servers will be set up, with automatic forwarding.
done-serve --static --key ~/.localhost-ssl/private.pem --cert ~/.localhost-ssl/cert.pem
Provides which rendering strategy to use. By default done-ssr waits for all asynchronous tasks to complete before serializing HTML and returning that to the browser. The options are:
- safe: The default strategy as described above.
- incremental: This rendering strategy prioritizes returning HTML to the browser sooner. Along with the HTML a shim is sent that communicates with the server to receive rendering instructions. This allows a faster rendering experience in browsers that support HTTP2. This strategy will silently fall back to the safe strategy if HTTP2 is not supported. Using this option requires also providing --key and --cert flags, as HTTP2 requires SSL.
You can also use the server, with the same options, from JavaScript:
var server = require("done-serve");
server({
path: "path/to/dir"
});
See the latest releases on GitHub.
The DoneJS contribution guide has information on getting help, reporting bugs, developing locally, and more.