@cplabs/shield-server
v4.0.0
Published
[![Build Status](https://github.com/customer-portal-labs/shield-server/workflows/Build/badge.svg)](https://github.com/customer-portal-labs/shield-server/actions) [![npm version](https://img.shields.io/npm/v/@cplabs/shield-server?logo=npm)](https://www.npm
Downloads
10
Readme
Shield Server
Shield Server is a express middlewares bundle, which could help developer to bootstrap a backend project in few minutes.
The features provided by Shield Server
- Cross-Origin Resource Sharing (CORS)
- Compression
- History API
- JSend (JSON Response Specification)
- Reverse Proxy
- HTTP Header Security
- Splunk Logger (HEC - HTTP Event Collector)
- Error Handlers
Top features are powered by following popular middlewares:
- body-parser
- compression
- connect-history-api-fallback
- cookie-parser
- cors
- helmet
- http-proxy-middleware
- morgan
Getting Started
Installation
npm install @cplabs/shield-server
# or use yarn
yarn add @cplabs/shield-server
Usage
Codeless mode
# Default
shield-server .
Codeless CLI Configuration
- --port
- --cors
- --debug
- --history-api-fallback
- --ssl-cert
- --ssl-key
Middleware mode
const express = require('express');
const {
defaultMiddlewares,
defaultErrorHandlers,
logger,
} = require('@cplabs/shield-server');
const app = express();
app.use(defaultMiddlewares());
app.use(defaultErrorHandlers());
app.listen(8080, () => {
logger.info(`Server start...`);
});
Configuration
Default configs
https://github.com/customer-portal-labs/shield-server/blob/9394a255a6c7ee206730918e6f7fa1b4d63c0862/src/config.ts#L9-L27
Options
name
type String
The application name
compression
cors
corsOption
mode
static
api
fullstack
morganFormat
combined
common
dev
short
tiny
port
type int
default 8080
debug
type boolean
default false