@ducksclan/wrapper-express
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Wrapper express

This is wrapper for express based app

Getting started

You need to install this module as a dependency of your nodejs project with any package manager.

$ npm install @ducksclan/wrapper-express

or

$ yarn add @ducksclan/wrapper-express

Usage

This module allows to quickly create an express application with helmet, cors, cookie-parser and express-fingerprint middlewares. This module also provides an asynchronous request handler and tagging middleware that allows to collect ip address and fingerprint hash generated by express-fingerprint module.

// app.ts
import { initialization, taggingMiddleware } from '@ducksclan/wrapper-express';

let cookieSecret: string = 'secret';
let app = initialization(cookieSecret);

app.use(taggingMiddleware());

export default app;
// interfaces.ts

export interface UserLocals extends TaggedLoclas {
  user: User;
}
// saveUserMiddleware.ts
import { asyncMiddleware } from '@ducksclan/wrapper-express';
import { UserLocals } from './interfaces.ts';

const saveUserMiddleware = asyncMiddleware<any, UserLocals>(
  async (req, res, next) => {
    await repository.save(res.locals.user);
    next();
  }
);

export default saveUserMiddleware;

Links

Package Sidebar

Install

npm i @ducksclan/wrapper-express

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

25.4 kB

Total Files

22

Last publish

Collaborators

  • hitachi567