From e4ff4fe551f8f6a0e628e388741b6a49252a5fec Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Sun, 14 Jan 2018 19:40:34 +0100 Subject: [PATCH] Update --- compositor.json | 94 ------------------------------------------------- index.html | 6 ++-- 2 files changed, 3 insertions(+), 97 deletions(-) delete mode 100644 compositor.json diff --git a/compositor.json b/compositor.json deleted file mode 100644 index c322686..0000000 --- a/compositor.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "name": "Kikobeats/svr", - "version": "0.1.4", - "libraries": { - "xv": "^1.1.25" - }, - "title": "", - "branch": "", - "style": { - "name": "Material", - "componentSet": { - "nav": "nav/DarkAbsoluteNav", - "header": "header/GradientHeader", - "article": "article/BasicArticle", - "footer": "footer/BasicFooter" - }, - "fontFamily": "Roboto, sans-serif", - "heading": { - "fontWeight": 500, - "letterSpacing": "-0.01em" - }, - "colors": { - "text": "#212121", - "background": "#fff", - "primary": "#2196f3", - "secondary": "#1565c0", - "highlight": "#ff4081", - "border": "#e0e0e0", - "muted": "#f5f5f5" - }, - "layout": { - "centered": true, - "bannerHeight": "80vh", - "maxWidth": 896 - } - }, - "content": [ - { - "component": "nav", - "links": [ - { - "href": "http://Kikobeats.github.io/svr/", - "text": "Home" - }, - { - "href": "https://github.com/Kikobeats/svr", - "text": "GitHub" - }, - { - "href": "https://npmjs.com/package/svr", - "text": "npm" - } - ] - }, - { - "component": "header", - "heading": "svr", - "subhead": "Hot Module Replacement for HTTP Server", - "children": [ - { - "component": "ui/TweetButton", - "text": "svr: Hot Module Replacement for HTTP Server", - "url": "http://Kikobeats.github.io/svr/" - }, - { - "component": "ui/GithubButton", - "user": "Kikobeats", - "repo": "svr" - } - ], - "text": "v0.4.0" - }, - { - "component": "article", - "metadata": { - "source": "github.readme" - }, - "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", - "links": [ - { - "href": "https://github.com/Kikobeats/svr", - "text": "GitHub" - }, - { - "href": "https://github.com/Kikobeats", - "text": "Kikobeats" - } - ] - } - ] -} \ No newline at end of file diff --git a/index.html b/index.html index 83244f5..f9107d7 100644 --- a/index.html +++ b/index.html @@ -16,17 +16,17 @@ - + - + - +