# @gfilho/base-server

> A lightweight wrapper for Express that allows easily setup HTTP headers and SSL.

Latest version **1.0.1** (published 2019-05-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gfilho/base-server
pnpm add @gfilho/base-server
yarn add @gfilho/base-server
bun add @gfilho/base-server
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-05-15 |
| First published | 2019-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Gustavo S. S. Filho |
| Maintainers | gfilho |
| Keywords | express, rest, restful, router, app, api, https, ssl, http-header |

## Links

- npm: https://www.npmjs.com/package/@gfilho/base-server
- Repository: https://github.com/gfilho/base-server
- Homepage: https://github.com/gfilho/base-server#readme
- Issues: https://github.com/gfilho/base-server/issues
- npm.io page: https://npm.io/package/@gfilho/base-server

## Dependencies (9)

- [q](https://npm.io/package/q.md) ^1.4.1
- [nyc](https://npm.io/package/nyc.md) ^14.1.0
- [http](https://npm.io/package/http.md) 0.0.0
- [https](https://npm.io/package/https.md) ^1.0.0
- [express](https://npm.io/package/express.md) ^4.13.3
- [request](https://npm.io/package/request.md) ^2.54.0
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [jsonschema](https://npm.io/package/jsonschema.md) ^1.2.4
- [body-parser](https://npm.io/package/body-parser.md) ^1.0.2

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-05-15
- 1.0.0 — 2019-05-15
- 0.1.0 — 2019-04-21

## README

# @gfilho/base-server
A lightweight wrapper for Express that allows easily setup HTTP headers and SSL.

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8de6566518794445a0211569e86e9ae3)](https://app.codacy.com/app/gfilho/base-server?utm_source=github.com&utm_medium=referral&utm_content=gfilho/base-server&utm_campaign=Badge_Grade_Dashboard)
[![Build Status](https://travis-ci.com/gfilho/base-server.svg?branch=master)](https://travis-ci.com/gfilho/base-server)
[![codecov](https://codecov.io/gh/gfilho/base-server/branch/master/graph/badge.svg)](https://codecov.io/gh/gfilho/base-server)

## Getting Started

### Installation

```bashp
npm install @gfilho/base-server --save
```

### Simple Server
This is example show how create a simple REST server using the @gfilho/base-server:

``` js
var Server = require('@gfilho/base-server');

// Setup Server
const config = {
  router: {
    address: 'api',
    port: 1234,
  },
};

// Instance of Server
const server = new Server(config);

// Bind requests
server.get('/ping', (req, res) => {
  res.json({ msg: 'Ops! I received a GET' });
});

// Run Server
server.start();
```

### Complete Server
This is example show a REST server using all features allowed by @gfilho/base-server:
``` js
var Server = require('@gfilho/base-server');

// Setup Server
const config = {
  router: {
    address: 'api',
    port: 1234,
    header: {
      allowedMethods: 'GET PUT POST DEL',
      allowedHost: 'mydomain.com',
      allowedHeaders: 'MySpecialHeader',
      allowedCredentials: true,
    },
    ssl: {
      key: 'examples/ssl/key.pem',
      certificate: 'examples/ssl/server.crt',
    },
  },
};

// Instance of Server
const server = new Server(config);

// Bind requests
server.get('/ping', (req, res) => {
  res.json({ msg: 'Server https is alive' });
});

server.put('/ping', (req, res) => {
  res.json({ msg: 'Ops! I received a PUT' });
});

server.post('/ping', (req, res) => {
  res.json({ msg: 'Ops! I received a POST' });
});

server.delete('/ping', (req, res) => {
  res.json({ msg: 'Ops! I received a DEL' });
});

// Run Server
server.start();
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/@gfilho/base-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
