Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-page-middleware
Advanced tools
Connect middleware for rendering pages with React JavaScript Library.
This project is not actively maintained. Proceed at your own risk!
Middleware for building full page apps using React, JSX, and CommonJS.
If you want to get started with server rendered React apps, go directly to react-page. This project is the implementation of the router/server-side-page-assembler/packager.
###Features
###Requirements
- node (a more recent version)
- npm
###Install
Let npm do all the installing - just create a directory structure anywhere as follows:
yourProject/
├── package.json # Add npm dependencies here.
├── server.js # Start web server with `node server.js`
└── src # All your application JS.
├── index.js # localhost:8080/index.html routed here
└── pages # Configure the page root using pageRouteRoot
└── about.js # localhost:8080/about.html
List your dependencies in
package.json
:
// Shows how to depend on bleeding edge versions. One niceness of
// `react-page-middleware`, is depending on the main React repo as
// `require('React')` Not all JS packagers understand the pure git repo for
// React.
"dependencies": {
"React": "git://github.com/facebook/react.git",
"react-page-middleware": "git://github.com/facebook/react-page-middleware.git",
"connect": "2.8.3"
},
Download your project's dependencies:
cd yourProject
npm install
Create a
server.js
file that requiresreact-page-middleware
, and set the proper directory search paths and routing paths.
var reactMiddleware = require('react-page-middleware');
var REACT_LOCATION = __dirname + '/node_modules/react-tools/src';
var ROOT_DIR = __dirname;
var app = connect()
.use(reactMiddleware.provide({
logTiming: true,
pageRouteRoot: ROOT_DIR, // URLs based in this directory
useSourceMaps: true, // Generate client source maps.
projectRoot: ROOT_DIR, // Search for sources from
ignorePaths: function(p) { // Additional filtering
return p.indexOf('__tests__') !== -1;
}
}))
.use(connect['static'](__dirname + '/src/static_files'));
http.createServer(app).listen(8080);
Run the server and open index.html:
node server open http://localhost:8080/index.html
The react-page project has a much more thorough explanation of the motivation and features.
The default router is JavaScript-centric. You simply specify the path to the JS component you want to use to render the entire page. react-page for more information about the routing.
react-page-middleware
has them.
Just hit your browser's refresh button to run an always-up-to-date version of your app.
react-page-middleware
is a rapid development environment where you can experiment with
entirely new ways of building production web apps powered by React. It provides
a common environment that allows sharing of modules client/server architecture
prototypes.
In order to use this technology in a production environment, you would need to audit and verify that the server rendering strategy is safe and suitable for your purposes.
In particular, you would want to ensure that a proper server
sandbox is enforced. However, react-page
does run your UI rendering code
inside of contextify as a preliminary sandbox.
The packaging/transforming features of react-page
would not be needed in a
production environment where the packages can be prebuilt once, stored in a CDN
and not be repackaged on the fly, but the server rendering feature is very
compelling for production environments where page load performance is of great
concern.
Among other things, additional connect middleware should be added to prevent stack traces from showing up in the client.
FAQs
Connect middleware for rendering pages with React JavaScript Library.
We found that react-page-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.