# @lulea/http

> Lulea HTTP module provide HTTP management for your Node.js application. This module is based on the express framework. The particularity of this module is to create an HTTP server without any configuration. However, if you want to configure your server yo

Latest version **0.0.12** (published 2017-08-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @lulea/http
pnpm add @lulea/http
yarn add @lulea/http
bun add @lulea/http
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2017-08-10 |
| First published | 2017-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | liteboard |

## Links

- npm: https://www.npmjs.com/package/@lulea/http
- Repository: https://github.com/liteboard/lulea-http
- Homepage: https://github.com/liteboard/lulea-http#readme
- Issues: https://github.com/liteboard/lulea-http/issues
- npm.io page: https://npm.io/package/@lulea/http

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [morgan](https://npm.io/package/morgan.md) ^1.8.2
- [express](https://npm.io/package/express.md) ^4.15.3
- [body-parser](https://npm.io/package/body-parser.md) ^1.17.2

## Recent versions

- 0.0.12 (latest) — 2017-08-10
- 0.0.11 — 2017-08-10
- 0.0.10 — 2017-08-10
- 0.0.9 — 2017-08-10
- 0.0.8 — 2017-08-10
- 0.0.7 — 2017-07-30
- 0.0.6 — 2017-07-20
- 0.0.5 — 2017-07-17
- 0.0.4 — 2017-07-17
- 0.0.3 — 2017-07-16
- 0.0.2 — 2017-07-16
- 0.0.1 — 2017-07-16

## README

# Lulea HTTP

Lulea HTTP module provide HTTP management for your Node.js application. This module is based on the express framework. The particularity of this module is to create an HTTP server without any configuration. However, if you want to configure your server you can simply override all lulea configurations.

## Getting started

### Installation
```bash
    npm install --save @lulea/http
```

### Create HTTP Server

#### In plain JavaScript

```javascript
    const lulea = require('@lulea/http');
    const server = new lulea.Server();
    const router = lulea.Router();

    router.get('/', (req, res) => {
        return res.json({message: "Hello World!"});
    });

    server.routes(router);
    server.start();
```

#### In TypeScript

```typescript
    import { Server, Router } from "@lulea/http";

    const server = new Server();
    const router = Router();

    router.get('/', (req, res) => {
        return res.json({message: "Hello World!"});
    });

    server.routes(router);
    server.start();
```

### Default server options

Lulea gives you a preconfigured HTTP server with the following options that you can edit at any time in server configuration options:

#### Server

| Option      | Default value              |
|-------------|----------------------------|
| port        | process.env.PORT or "3000" |

#### Body parser

| Option                    | Default value                       |
|---------------------------|-------------------------------------|
| enable                    | true                                |
| urlEncoded.enable         | true                                |
| urlEncoded.extended       | false                               |
| urlEncoded.inflate        | true                                |
| urlEncoded.limit          | "100kb"                             |
| urlEncoded.parameterLimit | 1000                                |
| urlEncoded.type           | "application/x-www-form-urlencoded" |
| json.enable               | true                                |
| json.inflate              | true                                |
| json.limit                | "100kb"                             |
| json.strict               | true                                |
| json.type                 | "application/json"                  |
| raw.enable                | false                               |
| raw.inflate               | true                                |
| raw.limit                 | "100kb"                             |
| raw.type                  | "application/octet-stream"          |
| text.enable               | false                               |
| text.defaultCharset       | "utf-8"                             |
| text.inflate              | true                                |
| text.limit                | "100kb"                             |

#### Morgan

| Option | Default value |
|--------|---------------|
| enable | true          |
| format | "combined     |

### Built-in API endpoints

Lulea provides built-in API endpoints that you can enable or disable at any time in server configuration options

```json (enable by default)
  GET /health 
  {
    "status": "up",
    "uptime": 13.012
  }
```

```json
  GET /infos (disable by default)
  {
    "os": {
      "arch": "x64",
      "platform": "linux"
    },
    "app": {
      "pid": 21263
    }
  }
```
```json
  GET /metrics (disable by default)
  {
    "cpu": {
      "user": 428000,
      "system": 32000
    },
    "memory": {
      "rss": 43487232,
      "heapTotal": 21590016,
      "heapUsed": 14689264,
      "external": 650929
    }
  }
```


### Overload default server options

```javascript
const options = {
  port: "3000",
  bodyParser: {
    enable: true,
    urlEncoded: {
      enable: true,
      extended: false,
      inflate: true,
      limit: "100kb",
      parameterLimit: 1000,
      type: "application/x-www-form-urlencoded"
    },
    json: {
      enable: true,
      inflate: true,
      limit: "100kb",
      strict: true,
      type: "application/json"
    },
    raw: {
      enable: false,
      inflate: true,
      limit: "100kb",
      type: "application/octet-stream"
    },
    text: {
      enable: false,
      defaultCharset: "utf-8",
      inflate: true,
      limit: "100kb"
    }
  },
  morgan: { enable: true, format: "combined" },
  builtInEndpoints: {
    healthEndpoint: true,
    infosEndpoint: false,
    metricsEndpoint: false
  }
};
const server = new Server(options);
```

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