Git Product home page Git Product logo

aliv's People

Contributors

bernardbr avatar dependabot[bot] avatar doublesharp avatar ericmdantas avatar phillpassos avatar shuunen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aliv's Issues

avoid https cert errors

Hi :)

The default ssl certs are invalid (invalid common name), personnally I use sslfie (https://github.com/mkropat/sslfie) to generate valid certificates, here is how I did to use aliv with valid local certs :
for example lets say my local project is called "foobar", so I added 127.0.0.1 foobar.io to my hosts file then in the node_modules/aliv/lib/crt folder I executed :
sslfie -o server.crt -k server.key foobar.io

To trust these new certificates :

sudo apt install libnss3-tools
certutil -d sql:$HOME/.pki/nssdb -A -t P -n "Foobar" -i server.crt

That's it, after restarting browser, I can go to https://foobar.io:1307/ without having any https certificates errors :)

expose reload()

Right now, even though aliv will work on gulp, broccolli or any other build tool, it's only called once, when the user calls start().

From that point on, all the reloading logic is managed by aliv itself - but - that's a bit selfish.

The user might want to use both aliv's management of reloading and his own reload() logic.

aliv will keep doing its job to reload the browsers everytime some files change, but the user will be able to call reload() on his own too.

Socket hang up

From time to time, this error occurs.

This only happens when the server (proxied) is taking a longer amount of time to respond and the client refreshes the page or makes another call to the same endpoint.

Improve logs

As of right now, aliv's logs are pretty annoying and badly formatted.

It's a point that's easy enough to do and should be improved.

http -> https redirection

hi again :)

it would be great to redirect http to https when aliv is started in secure mode,

actually http is just not accessible.

I also tried with this conf :

{
	"quiet": false,
        "root": "dist/",
	"port": 3000,
	"host": "foobar.io",
	"secure": true,
	"proxy": true,
	"proxyWhen": "/^http:/",
	"proxyTarget": "https://foobar.io:3000"
}

should not watch test files

Depending on how the user separated the project's folder structure, source and test code might live inside the same folder.

aliv should know how to ignore the test files by default. So, files that end with .spec.{js,ts,coffee}, .test.{js,ts,coffee} or _test.{js,ts,coffee} should not be watched.

http/2

Even though express4 doesn't work out of the box with the http/2 module, one could do the following expressjs/express#2761:

const express = require('express');
const http2 = require('http2');

express.request.__proto__ = http2.IncomingMessage.prototype;
express.response.__proto__ = http2.ServerResponse.prototype;

const app = express();

// ...

Obviously that's a workaround and most likely have some caveats, like fallbacks and stuff like that. So we might be better of having the secure and http2 options separated.

[ng-fullstack] Cannot serve on host 0.0.0.0

Hi team,

I launched web server using file .alivrc with the following content:

{
    "quiet": false,
    "host": "0.0.0.0",
    "port": 3000,
    "secure": true,
    "pathIndex": "client/dev",
    "only": "client/dev/**/*",
    "proxy": true,
    "proxyWhen": "/api/path/to/proxy/*",
    "proxyTarget": "http://proxy-to-my-target:8080"
}

and I cannot connect to the web server. Sound like it didn't get the host value to launch the server.

Thank you,
Toan Vu

https proxy hangs forever

Ref: http-party/node-http-proxy#304

<!-- index.html -->

<!doctype html>
<html>
	<head>
		<title>proxy_https</title>
	</head>
	
	<body>
		<p id="info">!!!</p>
	
		<script>
			fetch('/api/abc')
				.then(r => r.json())
				.then(r => {
					document.getElementById("info").innerText = r.msg;
				})
		</script>
	</body>
</html>
// node's index.js

const express = require('express')
const app = express()
const fs = require('fs')
const path = require('path')
const https = require('https')

app.get('/api/abc', (req, res) => {
	res.json({
		msg: 'wut'
	})
})

let options = {
	ca: [
	  fs.readFileSync(path.join(__dirname, 'node_modules/aliv/lib/crt/server.csr'))
	],
	cert: fs.readFileSync(path.join(__dirname, 'node_modules/aliv/lib/crt/server.crt')),
	key: fs.readFileSync(path.join(__dirname, 'node_modules/aliv/lib/crt/server.key'))
}

https.createServer(options, this._app)
		   .listen(9876, () => {
			 console.info(9876);
		   });
// .alivrc

{
	"quiet": true,
	"port": 3000,
	"host": "127.0.0.1",
	"secure": true,
	"proxy": true,
	"proxyWhen": "/api/*",
	"proxyTarget": "https://127.0.0.1:9876"
}
// package.json

{
  "name": "proxy_https",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "sc": "aliv",
    "ss": "node index"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "aliv": "^1.4.1",
    "express": "^4.14.0"
  }
}

If you simply change everything that's in https to http, it works just fine.

create events

It should emit events the user could hook to and do whatever they wanted, things like:

let aliv = new Server();

aliv.on('start', () => {})
aliv.on('change', () => {})
aliv.on('reload', () => {})
aliv.on('proxy', () => {})
aliv.on('close', () => {})
aliv.on('error', () => {})

implement short options

--quiet will also work as -q
--noBrowser will also work as -nb
--port will also work as -p
--ignorewill also work as -ign

Road to 1.0

  • implement ignore option
  • implement only option
  • implement pathIndex option
  • implement proxy option
  • implement https option

Aliv crashes with node API

I have code like:

const serve = new Server({
    quiet: true,
    cors: true,
    host: 'localhost',
    port: 3000,
    only: './dev',
    reloadDelay: 1000,
    root: path.resolve(process.cwd(), 'dev')
});
serve.start();

And when hot reload is triggered, I got the error like:

image

I'm using:

Node: v14.17.0

aliv: 1.13.0

implement ignore options

We should have some default ones:

  • node_modules
  • bower_components
  • jspm_packages
  • test / tests
  • typings
  • coverage / unit_coverage
  • ???

bug - Deep routes

The following routes serve the content correctly:

  • /
  • /something/1

The following don't:

  • /something/1/2
  • /something/1/2/3/
  • /something/1/2/3/there

middlewares

A lot of times you'll want to do something before the browser is reloaded; like compiling less -> css, ts -> js and so on. That's where middlewares come in.

We should have a way the user can inform a bunch of callbacks and we'll run them before refreshing the page.

Add "timeout" feature

Been using this lib for a development server of a new project. Excellent work, thank you for having something simple, straightforward and powerful.

I have a suggested feature I'd like to see. Instead of reloading instantly on the first file change, setup a timeout that allows additional files to be affected before the reload.

This could be a simple "timeout" option added to the config, setting it to "100" would cause the server to wait 100 ms before sending a refresh after a file has changed.

This has come up as a problem quite a few times in my use case. I've got webpack watching for changes on typescript files to compile to js, then node-sass listening for changes to the sass files and compiling to CSS. Quite a few times I'll change CSS & TS files in the same save cycle, then when the server refreshes either the JS or CSS is a cycle behind (depending on which one compiled faster).

Accept .alivrc or aliv.config.js

Having a static json in .alivrc is not always ideal.. sometimes the user might want to use comments or write conditions to use a certain value - by using aliv.config.js that'll be possible.

// .alivrc
{
  "port": "1234",
  "https": true
}
// aliv.config.js
module.exports = {
  port: "1234",
  root: process.cwd(),
  http2: true, // doesn't work with node 11.x, see aliv#40
}

The user should use one or the other, but not both.

HTTP2 doesn't work?

npm install aliv
npx aliv --port 8081 --http2 --noBrowser --root output

Trying to navigate to http://127.0.0.1:8081 from Firefox results in:

The connection was reset

Trying to navigate to http://127.0.0.1:8081 from from Chrome results in:

This page isn’t working
127.0.0.1 didn’t send any data.
ERR_EMPTY_RESPONSE

If I remove the --http2, everything works as expected.

Node Version: v10.15.0
aliv Version: 1.11.4

env: node\r: No such file or directory

This error occurs because the end of line is not set as lf, it's set as whatever windows uses.

Create .editorconfigfile with:

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.