Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docs-server

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docs-server - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

<a name="1.2.0"></a>
# [1.2.0](https://github.com/lbwa/docs-server/compare/v1.1.0...v1.2.0) (2018-08-07)
<a name="1.1.0"></a>

@@ -2,0 +7,0 @@ # [1.1.0](https://github.com/lbwa/docs-server/compare/v1.0.3...v1.1.0) (2018-08-06)

4

package.json
{
"name": "docs-server",
"version": "1.2.0",
"version": "1.3.0",
"description": "A server which is used to build one of microservices for docs system",

@@ -19,3 +19,3 @@ "main": "dist/index.js",

"ts": "npx tsc",
"server": "node dist/index",
"server": "node dist/sample/dev",
"dev": "yarn run ts && yarn run server",

@@ -22,0 +22,0 @@ "commit": "git add . && git-cz",

@@ -15,2 +15,6 @@ # Docs-server [![npm](https://img.shields.io/npm/v/docs-server.svg)](https://www.npmjs.com/package/docs-server) [![CircleCI](https://circleci.com/gh/lbwa/docs-server.svg?style=svg)](https://circleci.com/gh/lbwa/docs-server) [![node](https://img.shields.io/node/v/docs-server.svg)](https://www.npmjs.com/package/docs-server)

- Support for customizing docs response headers
- Support for specifying minimum response size in bytes to turn on gzip
## Installing

@@ -55,2 +59,19 @@

headers: {
// default value: '*'
'Access-Control-Allow-Origin': '*',
// default value: 'origin'
'vary': 'origin',
// Notice: server will set 'Content-Type' header by default
// other response headers you want set
'Access-Control-Allow-Methods': 'GET,POST'
},
// minimum response size in bytes to turn on gzip
// default value: 1 bytes
threshold: 1
// extra static resource routes

@@ -57,0 +78,0 @@ extra: [

@@ -42,3 +42,4 @@ import Koa = require('koa')

port?: number | string
directory?: string
headers?: resHeaders
threshold?: number
extra?: extraRoute[]

@@ -45,0 +46,0 @@ filter?: Function

@@ -1,2 +0,2 @@

import { appOptions, extraRoute } from './config/types'
import { appOptions, extraRoute, server } from './config/types'
import Gen from './generator'

@@ -23,2 +23,4 @@ import http = require('http')

* @param {String} port server port
* @param {Object} headers custom response headers
* @param {Number} threshold minimum size in bytes to turn on gzip
* @param {extraRoute[]} extra extra static resources routes

@@ -38,2 +40,4 @@ * @param {Function} filter a filter function for filtering origin doc route

port = '8800',
headers = {},
threshold = 1,
extra = [],

@@ -56,2 +60,4 @@ filter

port,
headers,
threshold,
extra,

@@ -87,2 +93,4 @@ filter

this.server = this.activateServer(
options.headers,
options.threshold,
this.gen.contentList,

@@ -113,4 +121,6 @@ options.extra,

/**
*build local server
* build local server
*
* @param {Object} headers custom response headers
* @param {Number} threshold minimum size in bytes to turn on gzip
* @param {Gen['contentList']} contentList content storage

@@ -121,5 +131,13 @@ * @param {extraRoute[]} extra extra static resources routes

*/
activateServer (contentList: Gen['contentList'], extra: extraRoute[], dest: string):http.Server {
activateServer (
customHeaders: server['customHeaders'],
threshold: server['threshold'],
contentList: Gen['contentList'],
extra: extraRoute[],
dest: string
):http.Server {
const port = this.options.port
const server = new Server({
customHeaders,
threshold,
contentList,

@@ -126,0 +144,0 @@ extra,

@@ -36,3 +36,3 @@ import Koa = require('koa')

function setResHeaders (customHeader: resHeaders) {
function setResHeaders (customHeaders: resHeaders) {
const baseHeader = {

@@ -44,3 +44,3 @@ // TODO: add filter for origin whitelist

const newHeader = Object.assign(baseHeader, customHeader)
const newHeader = Object.assign(baseHeader, customHeaders)

@@ -47,0 +47,0 @@ return async function (ctx: Koa.Context, next: Function) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc