# trailpack-express

> Express.js Trailpack. This pack binds the routes compiled in trailpack-router to a Express 4 or 5 Server.

Latest version **2.0.3** (published 2017-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install trailpack-express
pnpm add trailpack-express
yarn add trailpack-express
bun add trailpack-express
```

## 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 | 2.0.3 |
| Published | 2017-02-12 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Jimmy Aumard |
| Maintainers | trails |
| Keywords | trails, express, express4, express5, trailsjs, expressjs, webserver, trailpack |

## Links

- npm: https://www.npmjs.com/package/trailpack-express
- Repository: https://github.com/jaumard/trailpack-express
- Homepage: https://github.com/jaumard/trailpack-express#readme
- Issues: https://github.com/jaumard/trailpack-express/issues
- npm.io page: https://npm.io/package/trailpack-express

## Dependencies (12)

- [joi](https://npm.io/package/joi.md) ^10.0.2
- [cors](https://npm.io/package/cors.md) ^2.8.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.2
- [methods](https://npm.io/package/methods.md) ^1.1.2
- [trailpack](https://npm.io/package/trailpack.md) ^2.1.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.15.2
- [compression](https://npm.io/package/compression.md) ^1.6.2
- [consolidate](https://npm.io/package/consolidate.md) ^0.14.5
- [express-boom](https://npm.io/package/express-boom.md) ^1.0.0
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.4.3
- [express-session](https://npm.io/package/express-session.md) ^1.14.2
- [method-override](https://npm.io/package/method-override.md) ^2.3.6

## Recent versions

- 2.0.3 (latest) — 2017-02-12
- 3.0.0 (next) — 2018-03-20
- 2.0.7 — 2017-11-20
- 2.0.6 — 2017-10-31
- 2.0.5 — 2017-10-19
- 2.0.4 — 2017-04-05
- 2.0.2 — 2017-01-30
- 2.0.1 — 2017-01-24
- 2.0.0 — 2016-12-30
- 2.0.0-rc3 — 2016-12-08
- 2.0.0-rc1 — 2016-12-08
- 1.1.0 — 2016-12-06
- 1.0.15 — 2016-11-19
- 1.0.14 — 2016-08-31
- 1.0.11 — 2016-08-19
- … 11 more at https://npm.io/package/trailpack-express/versions

## README

# trailpack-express
:package: Express Trailpack

[![Gitter][gitter-image]][gitter-url]
[![NPM version][npm-image]][npm-url]
[![Linux + OSX Build Status][ci-image]][ci-url]
[![Windows Build Status][appveyor-image]][appveyor-url]
[![Code Climate][codeclimate-image]][codeclimate-url]
[![Follow @trailsjs on Twitter][twitter-image]][twitter-url]

This pack binds the routes compiled in [trailpack-router](https://github.com/trailsjs/trailpack-router)
to an [Express Server](http://expressjs.com/en/api.html). 

## Install

```
$ npm install --save trailpack-express
```

## Compatibility

This Trailpack is compatible with Express [v4](http://expressjs.com/en/4x/api.html) and [v5](https://github.com/expressjs/express/tree/5.0).

#### Express v4

```
$ npm install --save express@^4
```

#### Express v5

```
$ npm install --save express@^5.0.0-alpha.2
```

## Usage
Load in your trailpack config.

```js
// config/main.js
module.exports = {
  // ...
  packs: [
    require('trailpack-core'),
    require('trailpack-router'),
    require('trailpack-express')
  ]
}
```

## Static assets
```js
// config/main.js
module.exports = {
  // ...
  paths: {
    ...
    www: path.resolve(__dirname, '..', 'public')
    ...
  }
}
```

## View Config
Choose a template engine.

```js
// config/views.js
module.exports = {
  engine: 'pug'
}
```

Then simply write your views in a directory called 'views'!

## Configuration

See [`config/web.js`](https://github.com/trailsjs/trailpack-express/blob/master/archetype/config/web.js) for a full example.

#### `express`
Require field to set express version to use by setting `express: require('express')`

#### `cors`
Optional field to configure CORS, can be a boolean or an object (see https://github.com/expressjs/cors#configuring-cors)

#### `port`
The port to listen on. `3000` by default. Can also be set via the `PORT` environment variable.

#### `host`
The hostname of the server.

#### `cache`
The number of seconds to cache flat files on disk being served by Express

#### `ssl`
SSL options (`key`, `cert` or `pfx`) to allow set https protocol

#### `redirectToHttps`
Automatically redirect HTTP request to HTTPS if ssl enabled

#### `portHttp`
The port to listen for http protocol if ssl enabled. If you don't want http and https, don't add this field.

#### `middlewares`
Object to add custom middleware functions to Express, don't forget to add them into `middlewares.order` or they will not be called

### `init`
Method to customize express instance

## Contributing
We love contributions! Please check out our [Contributor's Guide](https://github.com/trailsjs/trails/blob/master/.github/CONTRIBUTING.md) for more
information on how our projects are organized and how to get started.

## License
[MIT](https://github.com/trailsjs/trailpack-express/blob/master/LICENSE)

[trails-image]: http://i.imgur.com/zfT2NEv.png
[trails-url]: http://trailsjs.io
[npm-image]: https://img.shields.io/npm/v/trailpack-express.svg?style=flat-square
[npm-url]: https://npmjs.org/package/trailpack-express
[ci-image]: https://img.shields.io/travis/trailsjs/trailpack-express.svg?style=flat-square&label=Linux%20/%20OSX
[ci-url]: https://travis-ci.org/trailsjs/trailpack-express
[appveyor-image]: https://img.shields.io/appveyor/ci/trailsjs/trailpack-express/master.svg?style=flat-square&label=Windows
[appveyor-url]: https://ci.appveyor.com/project/trailsjs/trailpack-express
[codeclimate-image]: https://img.shields.io/codeclimate/github/trailsjs/trailpack-express.svg?style=flat-square
[codeclimate-url]: https://codeclimate.com/github/trailsjs/trailpack-express
[gitter-image]: http://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square
[gitter-url]: https://gitter.im/trailsjs/trails
[twitter-image]: https://img.shields.io/twitter/follow/trailsjs.svg?style=social
[twitter-url]: https://twitter.com/trailsjs

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