# slowtify

> Decorators for Express

Latest version **0.0.6** (published 2020-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install slowtify
pnpm add slowtify
yarn add slowtify
bun add slowtify
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2020-12-20 |
| First published | 2020-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gensen Choy |
| Maintainers | choyg |
| Keywords | express, typescript, decorator |

## Links

- npm: https://www.npmjs.com/package/slowtify
- Repository: https://github.com/choyg/slowtify
- Issues: https://github.com/choyg/slowtify/issues
- npm.io page: https://npm.io/package/slowtify

## Dependencies (1)

- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2020-12-20
- 0.0.5 — 2020-12-20
- 0.0.4 — 2020-11-08
- 0.0.3 — 2020-11-02
- 0.0.2 — 2020-11-01
- 0.0.1 — 2020-11-01

## README

# Slowtify

TypeScript decorators for Express.

## Install

`npm install slowtify`

## Usage

```typescript
/* index.ts */
import Slowtify from "slowtify";
import express from "express";

const app = express();
app.use(express.json());
app.use(router);

const slow = new Slowtify({
  controllers: [UserController],
});
slow.useExpress(router);

app.listen(port, () => {
  console.info(`Listening on port ${port}`);
});
```

```typescript
/* UserController.ts */
@Controller("/users")
export class UserController {
  @Get(":id")
  async getUserById(@Params() params: UserParams) {
    return params.id;
  }

  @Post()
  async createUser(@Req() req: Request, @Body() body: CreateUser) {
    console.log(req.headers);
    return {
      body,
    };
  }
}
```

See the [full example](./examples/validation) that adds input validation.

## Metadata

Slowtify allows adding metadata to the route via the decorator. For example, `@Get('/', { permissions: ['test'] })` sets the permission for that route and will be accessible in the request object of the handler and middleware registered with Slowtify.

## Middleware

Express middleware can be added outside of Slowtify with the standard `app.use` syntax. To register middleware via Slowtify, `slowtify.use` adds the middleware function(s) to each route and appends route metadata to the request object.

Middleware execution order follows Express' syntax and will always be executed before the route handler.

Example:

```ts
slowtify.use((req, res, next) => {
  console.log(req.metadata);
  next();
});
```

# License

[MIT](./LICENSE)

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