stealify / server-harp Goto Github PK
View Code? Open in Web Editor NEWThe Core Server and Cli
License: Apache License 2.0
The Core Server and Cli
License: Apache License 2.0
/*
Usage Example:
dssrv.vhostrouter = require(express-domainrouter')
// Optain vhost config
dssrv.vhostrouter.locals.vhosts = worker.options.vhosts || [ 'default' ]
dssrv.vhostrouter.locals.vhosts.forEach(function(domain) {
dssrv.debug('vhosts Registered: %s , %s', domain , 'replace')
// dssrv.vhostrouter.locals.hostDictionary[domain] = replace
})
// dssrv.debug('vhosts Registered: %s , %s', 'default' , 'videoreplace')
// var apiAPP = require(worker.options.expressApps.bla.app)(worker.options.expressApps.bla.config)
// dssrv.vhostrouter.locals.hostDictionary['domain'] = apiAPP
*/
var express = require('express')
var vhostrouter = express('dssrv:worker:'+process.pid+':vhosts');
vhostrouter.locals.hostDictionary = vhostrouter.locals.hostDictionary || {}
vhostrouter.use(
function replaceDevHosts(req, res, next) {
// replace dev test hosts
req.headers.originalHost = req.headers.Host || req.headers.host
req.headers.Host = req.headers.originalHost.replace('.new','')
req.headers.host = req.headers.originalHost.replace('.new','')
req.headers.Host = req.headers.originalHost.replace('.local','')
req.headers.host = req.headers.originalHost.replace('.local','')
next()
}, function vhost(req, res, next){
var debug = require('debug')('dssrv:worker:'+process.pid+':Vhost');
debug('VHOSTS EXEC: ' + JSON.stringify(req.headers))
// debug('VHOSTS EXEC: ' + JSON.stringify(req.app.locals.hostDictionary))
// console.log(req.app.locals.hostDictionary)
if (!req.headers.host) return next();
var host = req.headers.host.split(':')[0];
if (req.trustProxy && req.headers["x-forwarded-host"]) {
host = req.headers["x-forwarded-host"].split(':')[0];
}
var server = req.app.locals.hostDictionary[host];
if (!server){
server = req.app.locals.hostDictionary['*' + host.substr(host.indexOf('.'))];
}
if (!server){
server = req.app.locals.hostDictionary['default'];
}
// console.log(JSON.stringify(Vhost.hostDictionary))
// console.log()
if (!server) return next();
if ('function' == typeof server) return server(req, res, next);
// server.emit('request', req, res);
next()
}
);
module.exports = vhostrouter
if a domain
remove change reorder middelware as needed and export it as own app.
steal server demonstrates that powerfull via its use of done-serve ๐ฏโโ๏ธ
https://github.com/steal-server/server/blob/master/lib/helpers.js
replace with fsexists checks.
if it has a package.json lets serve what ever is files is set to
We need to integrate our C Server directly into this
then default proxy to this and make config option for static files and other proxys directly in this.
so we default to this but! allow the user to configure something totally diffrent we don't block that!
So for every host reflect config in realtime! via a express direktspeed framework middelware
maybe document the mruby support but i think we should first finish experiment DIREKTSPEED-X985332-9 wich is about the direct nativ nodejs bindings.
On registry https://registry.npmjs.org/
, the "latest" version (v2.2.5) of dependency cross-spawn-async
has the following deprecation notice:
cross-spawn no longer requires a build toolchain, use it instead
Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.
Affected package file(s): package.json
If you don't care about this, you can close this issue and not be warned about cross-spawn-async
's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:
"suppressNotifications": ["deprecationWarningIssues"]
Scan every folder under root/
find package.json if not exist assume default harp project
if finds package.json use it to find out if we are a express,feathers,donejs Application
if we are simply surfe that.
TODO: Find out what happens with individual listen stuff maybe make a master pollifil for that
steal-prerender could offer a middelware to link all modules from
the path
function npmls(cb) {
require('child_process').exec('npm ls --depth 0 --json', function(err, stdout, stderr) {
if (err) return cb(err)
cb(null, JSON.parse(stdout));
});
}
npmls(console.log);
npm.commands.ls(args, [silent,] callback)
console.log(Object.keys(require('./package.json').dependencies));
we will probally use rootRequire try catched
---- https://gist.github.com/branneman/8048520#comment-1412502
2. The Global
In your app.js:
global.__base = __dirname + '/';
In your very/far/away/module.js:
var Article = require(__base + 'app/models/article');
Courtesy of @a-ignatov-parc. Another simple solution which increases obviousness, simply wrap the require() function with one relative to the path of the application's entry point file.
Place this code in your app.js, again before any require() calls:
global.rootRequire = function(name) {
return require(__dirname + '/' + name);
}
You can then require modules like this:
var Article = rootRequire('app/models/article');
Install some module:
npm install app-module-path --save
In your app.js, before any require() calls:
require('app-module-path').addPath(__dirname + '/app');
or Use NODE_PATH=. or project root for require
hacky method
process.env.NODE_PATH = __dirname;
require('module').Module._initPaths();
I've been using symlinks with the following structure:
/node_modules
/package.json
/src
/node_modules
/client -> ../client
/server -> ../server
/shared -> ../shared
/client
/apps
/main
/test
main.spec.js
index.js
/modules
/foo
/test
foo.spec.js
index.js
/server
/apps
/modules
/shared
it also solves the problem of not know where the modules come from because all app modules have client/server/shared prefixes in require paths
# General Rule
Look on some defined requests if file is not there if we can find a alternate version for it via preprocessing and returning that
# Look on Some Defined Requests if the
Replace with fs-extra
At present we have one Project Type: [Prerender/Harp]
Allows to register routes in nginx when used as proxy for 404 requests dynamic
Directory Structure
Project Directory
|
|--| server
|--| ssr.js
|--| public
|--| package.json
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates are currently rate limited. Click on a checkbox below to force their creation now.
These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
package.json
steal git+https://github.com/stealify/steal/
compression ^1.6.1
debug ^4.0.0
done-serv git+https://github.com/donejs/done-serve
done-ssr-middleware git+https://github.com/donejs/done-ssr-middleware
express ^4.13.4
http-proxy ^1.13.2
infanticide ^1.0.1
donejs-spdy ^3.4.7
async ^2.0.1
commander ^4.0.0
download-github-repo ^0.1.3
dssrv-envy-json ^0.2.1
escape-html ^1.0.3
mime 2.0.3
fs-extra ^5.0.0
parseurl ^1.3.1
pause ^0.1.0
send ^0.15.0
chalk ^2.0.0
basic-auth ^2.0.0
cross-spawn-async ^2.0.0
q ^1.4.1
coveralls-send 0.0.2
dotdotdot 1.7.0
es6-promise 4.1.1
guide-automation 0.3.11
is-appveyor 1.0.0
istanbul 0.4.5
jshint 2.9.5
mocha 7.0.0
mocha-lcov-reporter 1.3.0
mockery 2.1.0
nixt 0.5.0
node-fetch 2.6.1
request 2.88.0
should 13.1.2
stream-when 1.0.0
.travis.yml
node 4.5
node 5.0
node 7.5
The idea is to catch the first request process it then configure the real target and return its response
we should not get a secund req after that because the other new configured target takes over.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.