Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/protontype/proton-compression
- Owner: protontype
- Created: 2018-04-17T13:49:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-04T18:11:46.000Z (almost 6 years ago)
- Last Synced: 2024-03-26T20:49:29.426Z (8 months ago)
- Topics: compression, expressjs, middleware, nodejs, protontype, rest-api, typescript
- Language: TypeScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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) {
...
}
}
```