1 | # Neutrino Start Server Middleware
|
2 | [![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url]
|
3 |
|
4 | `neutrino-middleware-start-server` is Neutrino middleware for starting a Node.js server for a file upon
|
5 | completion of a build.
|
6 |
|
7 | ## Requirements
|
8 |
|
9 | - Node.js v6.10+
|
10 | - Yarn or npm client
|
11 | - Neutrino v7
|
12 |
|
13 | ## Installation
|
14 |
|
15 | `neutrino-middleware-start-server` can be installed via the Yarn or npm clients.
|
16 |
|
17 | #### Yarn
|
18 |
|
19 | ```bash
|
20 | ❯ yarn add neutrino-middleware-start-server
|
21 | ```
|
22 |
|
23 | #### npm
|
24 |
|
25 | ```bash
|
26 | ❯ npm install --save neutrino-middleware-start-server
|
27 | ```
|
28 |
|
29 | ## Usage
|
30 |
|
31 | `neutrino-middleware-start-server` can be consumed from the Neutrino API, middleware, or presets. Require this package
|
32 | and plug it into Neutrino:
|
33 |
|
34 | ```js
|
35 | // Using function middleware format
|
36 | const server = require('neutrino-middleware-start-server');
|
37 |
|
38 | // Use with default options, starting the server
|
39 | // for the main entry point, neutrino.options.entry
|
40 | neutrino.use(server);
|
41 |
|
42 | // Usage with custom server file to start
|
43 | neutrino.use(server, { name: 'custom.js' });
|
44 | ```
|
45 |
|
46 | ```js
|
47 | // Using object or array middleware format
|
48 |
|
49 | // Use with default options, starting the server
|
50 | // for the main entry point, neutrino.options.entry
|
51 | module.exports = {
|
52 | use: ['neutrino-middleware-start-server']
|
53 | };
|
54 |
|
55 | // Usage with custom server file to start
|
56 | module.exports = {
|
57 | use: [
|
58 | ['neutrino-middleware-start-server', {
|
59 | name: 'custom.js'
|
60 | }]
|
61 | ]
|
62 | };
|
63 | ```
|
64 |
|
65 | By default this middleware will start a server with the single entry point configured in Neutrino.
|
66 | This middleware optionally accepts an object with a `name` property for a path to a module which to start the server.
|
67 |
|
68 | ## Customization
|
69 |
|
70 | `neutrino-middleware-start-server` creates some conventions to make overriding the configuration easier once you are
|
71 | ready to make changes.
|
72 |
|
73 | ### Plugins
|
74 |
|
75 | The following is a list of plugins and their identifiers which can be overridden:
|
76 |
|
77 | | Name | Description | Environments and Commands |
|
78 | | --- | --- | --- |
|
79 | | `start-server` | Start a Node.js for a configured entry point or specified file. | all |
|
80 |
|
81 | ### Debugging
|
82 |
|
83 | You can start the Node.js server in `inspect` mode to debug the process by setting `neutrino.options.debug` to `true`.
|
84 | This can be done from the [API](https://neutrino.js.org/api#optionsdebug) or the
|
85 | [CLI using `--debug`](https://neutrino.js.org/cli#-debug).
|
86 |
|
87 | ## Contributing
|
88 |
|
89 | This middleware is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo
|
90 | containing all resources for developing Neutrino and its core presets and middleware. Follow the
|
91 | [contributing guide](https://neutrino.js.org/contributing) for details.
|
92 |
|
93 | [npm-image]: https://img.shields.io/npm/v/neutrino-middleware-start-server.svg
|
94 | [npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-start-server.svg
|
95 | [npm-url]: https://npmjs.org/package/neutrino-middleware-start-server
|
96 | [slack-image]: https://neutrino-slack.herokuapp.com/badge.svg
|
97 | [slack-url]: https://neutrino-slack.herokuapp.com/
|