@bast1oncz/react-server
TypeScript icon, indicating that this package has built-in type declarations

6.0.5 • Public • Published

@bast1oncz/react-server

This package lets you to create a production server for a react application with:

  • Very simple setup
  • Use controllers that you need and are supported by your platform

Installation

npm install @bast1oncz/react-server --save

Project setup

// serverProd.js

const {createServer, RequireHostController, BotRequestController, FileController, ResourceController} = require('@bast1oncz/react-server')

createServer(process.env.PORT || 3100, [
    // keep one host because of SEO purposes (if process.env.REQUIRE_HOST is not defined, controller is not used)
    process.env.REQUIRE_HOST && new RequireHostController('RequireHostController', process.env.REQUIRE_HOST),
    // serves resource files; the requested url path must start with that last folder pathname
    new ResourceController('ResourceController', `${__dirname}/deploy/dist`),
    // serves full rendered html to bots
    new BotRequestController('BotRequestController', process.env.PROTOCOL || 'http'),
    // serves raw html document with application script to users
    new FileController('AppDocumentController', `${__dirname}/deploy/app.html`)
])
// package.json

{
    "start": "node serverProd.js",
}

Run server

npm start

Package Sidebar

Install

npm i @bast1oncz/react-server

Weekly Downloads

5

Version

6.0.5

License

UNLICENSED

Unpacked Size

45.1 kB

Total Files

36

Last publish

Collaborators

  • bast1oncz