From 246430164954f66b2e4dda5f10cb0f58530a8367 Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Sun, 14 Jan 2018 19:37:44 +0100 Subject: [PATCH] Update compositor.json via compositor.io --- compositor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compositor.json b/compositor.json index 367a2bf..c322686 100644 --- a/compositor.json +++ b/compositor.json @@ -75,7 +75,7 @@ "metadata": { "source": "github.readme" }, - "html": "

\n
\n \n
\n
\n

\n\n

\n\n\n\n\n\n

\n
\n

Hot Module replacement (HMR) capabilities for any HTTP Server.

\n
\n

The idea behind this project is smart reload, avoiding reload completely the process. It just reload the code that changes!

\n

It's similar micro-dev, but out of the box for any framework that use http.Server.listen() interface.

\n

Installation

\n

You can install it as global

\n
$ npm install svr --global

Or use it as part of your development workflow as a devDependency:

\n
$ npm install svr --save-dev

Usage

\n

Getting Started

\n

After installation, just call it:

\n
$ svr

We recommend add svr as npm script:

\n
{\n  "scripts": {\n    "dev": "srv"\n  }\n}

Now, running npm run dev it will be start your HRM development server:

\n
$ npm start\n\n  ┌───────────────────────────────────────────────────┐\n  │                                                   │\n  │   my-express-api is running!                      │\n  │                                                   │\n  │   • Local:            http://localhost:3000       │\n  │   • On Your Network:  http://192.168.1.106:3000   │\n  │                                                   │\n  └───────────────────────────────────────────────────┘

svr is assuming you have a main file declared in your package.json in the project directory.

\n

Otherwise, you can provide the file path as first argument:

\n
$ svr src/server/routes.js

The only requirement is define the main file of your server as exported function that follow this interface:

\n
module.exports = (app, express) => {\n/* your awesome code here */\n}

If your project directory is different from the current directory you can specify it as well using -d or --cwd flag:

\n
$ svr src/server/routes.js --cwd=~/Projects/my-express-api

Type svr --help to get all the information.

\n

Watching for changes

\n

After start, whatever file modification in the project directory will be listened by svr automagically:

\n
  ┌───────────────────────────────────────────────────┐\n  │                                                   │\n  │   my-express-api is running!                      │\n  │                                                   │\n  │   • Local:            http://localhost:3000       │\n  │   • On Your Network:  http://192.168.1.106:3000   │\n  │                                                   │\n  └───────────────────────────────────────────────────┘\n\n   ℹ 18:32:42 modified index.js

If you need to reload the server on demand, just type rs:

\n
  ┌───────────────────────────────────────────────────┐\n  │                                                   │\n  │   my-express-api is running!                      │\n  │                                                   │\n  │   • Local:            http://localhost:3000       │\n  │   • On Your Network:  http://192.168.1.106:3000   │\n  │                                                   │\n  └───────────────────────────────────────────────────┘\n\n   ℹ 18:32:42 modified index.js\n   rs\n   ℹ 18:34:07 restart index.js

svr only will be listen files in the current directory by default.

\n

You can use -w or --watch to add more file path to be listened

\n
$ svr src/server/routes.js

Type svr --help to get all the information.

\n

Ignoring files

\n

svr takes into consideration ignore non relevant files.

\n

By default, it will be to ignore:

\n\n

You can declare:

\n\n

If you need to add a specific file to ignore, use i or --ignore flag:

\n
$ svr -i .cache -i public

Tips

\n

Development Server

\n

This could be a good start point for a HTTP server:

\n
const isProduction = process.env.NODE_ENV === 'production'\n\nmodule.exports = (app, express) => {\n  /* here you can do whatever you want */\n  app\n    .use(require('helmet')())\n    .use(require('compression')())\n    .use(require('cors')())\n    .use(require('jsendp')())\n    .use(require('express-status-monitor')())\n    .use(bodyParser.urlencoded({ extended: true }))\n    .use(bodyParser.json())\n    .use(require('morgan')(isProduction ? 'combined' : 'dev'))\n    .use(express.static('static'))\n    .disable('x-powered-by')\n\n  app.get('/', async function (req, res) {\n    return res.send('hello world')\n  })\n\n  return app\n}

Production Server

\n

svr is oriented just for development scenarios.

\n

Under production, simply create the boostraping server that you need.

\n

For example, you can take this server.js as production server:

\n
'use strict'\n\nconst express = require('express')\n\nconst app = express()\n\nrequire('./index')(app, express)\n\nconst port = process.env.PORT || process.env.port || 3000\nconst { name } = require('../package.json')\n\napp.listen(port, function () {\n  console.log(`${name} is running at http://localhost:${port}`)\n})

Just add it as npm start script

\n
{\n  "scripts": {\n    "start": "node server.js"\n  }\n}

That's all.

\n

License

\n

MIT © Kiko Beats.

\n" + "html": "

\n
\n \n
\n
\n

\n\n

\n\n\n\n\n

\n
\n

Hot Module replacement (HMR) capabilities for any HTTP Server.

\n
\n

The idea behind this project is smart reload, avoiding reload completely the process. It just reload the code that changes!

\n

It's similar micro-dev, but out of the box for any framework that use http.Server.listen() interface.

\n

Installation

\n

You can install it as global

\n
$ npm install svr --global

Or use it as part of your development workflow as a devDependency:

\n
$ npm install svr --save-dev

Usage

\n

Getting Started

\n

After installation, just call it:

\n
$ svr

We recommend add svr as npm script:

\n
{\n  "scripts": {\n    "dev": "srv"\n  }\n}

Now, running npm run dev it will be start your HRM development server:

\n
$ npm start\n\n  ┌───────────────────────────────────────────────────┐\n  │                                                   │\n  │   my-express-api is running!                      │\n  │                                                   │\n  │   • Local:            http://localhost:3000       │\n  │   • On Your Network:  http://192.168.1.106:3000   │\n  │                                                   │\n  └───────────────────────────────────────────────────┘

svr is assuming you have a main file declared in your package.json in the project directory.

\n

Otherwise, you can provide the file path as first argument:

\n
$ svr src/server/routes.js

The only requirement is define the main file of your server as exported function that follow this interface:

\n
module.exports = (app, express) => {\n/* your awesome code here */\n}

If your project directory is different from the current directory you can specify it as well using -d or --cwd flag:

\n
$ svr src/server/routes.js --cwd=~/Projects/my-express-api

Type svr --help to get all the information.

\n

Watching for changes

\n

After start, whatever file modification in the project directory will be listened by svr automagically:

\n
  ┌───────────────────────────────────────────────────┐\n  │                                                   │\n  │   my-express-api is running!                      │\n  │                                                   │\n  │   • Local:            http://localhost:3000       │\n  │   • On Your Network:  http://192.168.1.106:3000   │\n  │                                                   │\n  └───────────────────────────────────────────────────┘\n\n   ℹ 18:32:42 modified index.js

If you need to reload the server on demand, just type rs:

\n
  ┌───────────────────────────────────────────────────┐\n  │                                                   │\n  │   my-express-api is running!                      │\n  │                                                   │\n  │   • Local:            http://localhost:3000       │\n  │   • On Your Network:  http://192.168.1.106:3000   │\n  │                                                   │\n  └───────────────────────────────────────────────────┘\n\n   ℹ 18:32:42 modified index.js\n   rs\n   ℹ 18:34:07 restart index.js

svr only will be listen files in the current directory by default.

\n

You can use -w or --watch to add more file path to be listened

\n
$ svr src/server/routes.js

Type svr --help to get all the information.

\n

Ignoring files

\n

svr takes into consideration ignore non relevant files.

\n

By default, it will be to ignore:

\n\n

You can declare:

\n\n

If you need to add a specific file to ignore, use i or --ignore flag:

\n
$ svr -i .cache -i public

Tips

\n

Development Server

\n

This could be a good start point for a HTTP server:

\n
const isProduction = process.env.NODE_ENV === 'production'\n\nmodule.exports = (app, express) => {\n  /* here you can do whatever you want */\n  app\n    .use(require('helmet')())\n    .use(require('compression')())\n    .use(require('cors')())\n    .use(require('jsendp')())\n    .use(require('express-status-monitor')())\n    .use(bodyParser.urlencoded({ extended: true }))\n    .use(bodyParser.json())\n    .use(require('morgan')(isProduction ? 'combined' : 'dev'))\n    .use(express.static('static'))\n    .disable('x-powered-by')\n\n  app.get('/', async function (req, res) {\n    return res.send('hello world')\n  })\n\n  return app\n}

Production Server

\n

svr is oriented just for development scenarios.

\n

Under production, simply create the boostraping server that you need.

\n

For example, you can take this server.js as production server:

\n
'use strict'\n\nconst express = require('express')\n\nconst app = express()\n\nrequire('./index')(app, express)\n\nconst port = process.env.PORT || process.env.port || 3000\nconst { name } = require('../package.json')\n\napp.listen(port, function () {\n  console.log(`${name} is running at http://localhost:${port}`)\n})

Just add it as npm start script

\n
{\n  "scripts": {\n    "start": "node server.js"\n  }\n}

That's all.

\n

License

\n

MIT © Kiko Beats.

\n" }, { "component": "footer",