Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var http = require('http')
var browserify = require('browserify')
var literalify = require('literalify')
var React = require('react')
var ReactDOMServer = require('react-dom/server')
var DOM = require('react-dom-factories')
var AWS = require('aws-sdk')
// Our router, DB and React components are all shared by server and browser
// thanks to browserify
var router = require('./router')
var db = require('./db')
var body = DOM.body, div = DOM.div, script = DOM.script
var App = React.createFactory(require('./App'))
// A variable to store our JS, which we create when /bundle.js is first requested
var BUNDLE = null
// Just create a plain old HTTP server that responds to our route endpoints
// (and '/bundle.js')
var server = http.createServer(function(req, res) {
// See if we have any component routes matching the requested URL
var route = router.resolve(req.url)
if (route) {
res.setHeader('Content-Type', 'text/html; charset=utf8')
var http = require('http')
var browserify = require('browserify')
var literalify = require('literalify')
var React = require('react')
var ReactDOMServer = require('react-dom/server')
var DOM = require('react-dom-factories')
var body = DOM.body, div = DOM.div, script = DOM.script
// This is our React component, shared by server and browser thanks to browserify
var App = React.createFactory(require('./App'))
// A variable to store our JS, which we create when /bundle.js is first requested
var BUNDLE = null
// Just create a plain old HTTP server that responds to two endpoints ('/' and
// '/bundle.js') This would obviously work similarly with any higher level
// library (Express, etc)
http.createServer(function(req, res) {
// If we hit the homepage, then we want to serve up some HTML - including the
// server-side rendered React component(s), as well as the script tags
// pointing to the client-side code
if (req.url === '/') {