@velop/server
v0.3.2
Published
Serve one or more react apps! - Custom routes, HotReloading, Authenticated Apps/routes, Relay, Webpack ++
Downloads
29
Readme
velop-server
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/server
or
$ yarn add @velop/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/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
- koa - Koa server, why? its faster than express
- koa-compress - zlib compressing
- koa-etags - support for etags
- koa-helmet - header/content security
- koa-logger - development logging
- kcors - Cross-Origin Resource Sharing(CORS)
- passport - authentication layer
- ddos - dos/ddos protection
- webpack - module bundler
- graphql - GraphQL
- relay - Relay
- found - Found router
- react-hot-loader - Tweak React components in real time
- webpack-hot-middleware - Webpack hot reloading
- winston - Winston logger
Thanks to:
- taion for found router
- sokra for webpack
- glenjamin for webpack hot middleware
- richardscarrott for webpack hot server middleware
- jkettmann for a good startupkit and many more ++