@velop-pkg/server

Serve one or more react apps! - Custom routes, HotReloading, Authenticated Apps/routes, Relay, Webpack ++

Repo moved, PLEASE USE MOVE TO NEW REPO: @velop/server
Last updated 10 months ago by stoffern .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @velop-pkg/server 
SYNC missed versions from official npm registry.

velop-server

Greenkeeper badge Travis npm npm Coverage Status code style: prettier

Serve one or more React apps with one simple call. Supports Universal rendering, Webpack, HotReloading, Relay, Passport, FoundRouter, Graphql out of the box! Fully editable setup with a simple set of functions and commands. You can also add custom routes or static paths at your needs. Even add a authentication layer on top of the routes or apps you what! All this is possible with a simple set of functions.

Why?

This is not a standardization nor a boilerplate or startupkit. This is a engine that can serve the js for you in the way you want. A developer should not put resources into setting up core server, only provide details of what they want to serve and how to do it. The rest will @velop/server take care of!

Why not Next.js?

NextJS is a great tool for creating a boilerplate setup that you can edit for your needs. Full cretid to Zeit for some awesome work! But it has some core problems like serving multiple apps, custom static folders, authentication to routes, or just serving other then react apps. @velop/server aims to solve these problems and with a more simple solution. Calling functions and not configuring files.

Table of Contents

Installation

$ npm i -S @velop-pkg/server
or
$ yarn add @velop-pkg/server

Getting started

Create a awsome react app app/Routes.js with found routing/navigation Remember you must return a found makeRouteConfig.

Create a new file server.js with contents:

const Server = require('@velop-pkg/server')

var server = new Server({
  environment: 'development',
  hostname: 'localhost',
  port: 3000,
});

//To add a file or a folder with routes?
server.addRoute('routes/');

//To add a React app with serverside render support
server.addReactRoute(
  '',   // URI prefix
  path.resolve(process.cwd(), 'app/Routes.js'), //path to APP file
);

//Start server!
server.start();

Create a .babelrc file for your needs:

{
  "presets": [
    "react",
    "stage-0"
  ],
  "plugins": [
    "transform-runtime"
  ],
  "env": {
    "development": {
      "plugins": ["react-hot-loader/babel"]
    }
  }
}

Run the server:node server.js Good luck!

Features

Todo:

  • [x] Add support for custom routes
  • [x] Add support for multiple React apps with serverside render (SSR)
  • [ ] Allow middleware for react paths (example: authentication)
  • [x] Add support for Passport
  • [x] Add support for Relay
  • [x] Add support for custom index.html file for SSR
  • [x] Create examples
  • [x] Better documentation

Thanks to:

Current Tags

  • 0.0.2                                ...           latest (10 months ago)

2 Versions

  • 0.0.2 [deprecated]           ...           10 months ago
  • 0.0.1 [deprecated]           ...           10 months ago
Maintainers (1)
Downloads
Today 2
This Week 2
This Month 8
Last Day 0
Last Week 0
Last Month 2
Dependencies (73)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |