@axon/web-server
v0.0.11
Published
Axon web server is based on lightweight [ExpressJS](http://expressjs.com/) framework. It allows you to config server in simple notation way.
Downloads
25
Readme
Axon Web Server
Axon web server is based on lightweight ExpressJS framework. It allows you to config server in simple notation way.
Installation
$ npm i --save @axon/web-server
How to use
// /server.js file
const server = require('axon-web-server');
const express = require('express');
const app = express();
server.start(app, {
// Web server port
port: 3000, // by default
// Routes which don't require auth
exclude: [
'/public/page',
'/api/public/resource'
],
// Session configuration
session: {
secret: 'S0iCXOFtfL',
resave: false,
saveUninitialized: true
},
// Path to login html file
loginView: path.resolve(__dirname, 'views/login.html'),
// Path for static files
static: path.join(__dirname, 'dist'),
// Webpack configuration
webpack: {
compile: require('./webpack.config.babel'),
middleware: require('./webpack.config.babel')
},
// Environment config
environment: require('./environment')
});Run in console: $ node server.js
Configuration
port: number
Set application web server port. Defaults to 3000.
session: object
Set session configuration. Documentation https://github.com/expressjs/session. It's no session by default.
Note: Login functionality activates if the session is configured.
session: {
secret: 'S0iCXOFtfL',
resave: false,
saveUninitialized: true
}exclude: array of strings
If the session is configured, then just /login path will be available without authorization.
But sometimes you need some public routes which don't require authorization.
exclude: [
'/landing',
'/api/public/countries'
]webpack: object
Webpack configuration to compile and webpack middleware in development environment. It requires two fields: compile (webpack building config https://webpack.js.org/configuration/#options) and middleware (webpack middleware config https://github.com/webpack/webpack-dev-middleware)
webpack: {
compile: require('./webpack.config.babel'),
// middleware options
middleware: require('./webpack.middleware.config')
}