Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/protontype/proton-compression

A compression middleware for Protontype
https://github.com/protontype/proton-compression

compression expressjs middleware nodejs protontype rest-api typescript

Last synced: 17 days ago
JSON representation

A compression middleware for Protontype

Awesome Lists containing this project

README

        

[![npm version](https://badge.fury.io/js/proton-compression.svg)](https://badge.fury.io/js/proton-compression)

# A compression middleware for Protontype

This module wrap [Compression](https://github.com/expressjs/compression) Nodejs module for use into a [Protontype](https://protontype.github.io/) project

# How to Use

## As Global Middleware

```typescript
let app = new ProtonApplication()
.addMiddlewareAs(CompressionMiddleware)
app.start();
```

## As Router Middleware

```typescript
@RouterClass({
baseUrl: "/tasks",
middlewares: [
new CompressionMiddleware()
]
})
export class TaskRouter extends ExpressRouter {
...
}

```
## As Route Middleware

```typescript
@RouterClass({baseUrl: "/tasks"})
export class TaskRouter extends ExpressRouter {
@Route({
endpoint: '/',
method: Method.POST,
middlewares: [new CompressionMiddleware()]
})
addTask(params: RouterFunctionParams) {
...
}
}
```