7.4.0 • Published 7 months ago

@gasket/plugin-express v7.4.0

Weekly downloads
37
License
MIT
Repository
github
Last release
7 months ago

@gasket/plugin-express

Adds Express to your application.

Guides

Installation

npm i @gasket/plugin-express

Update your gasket file plugin configuration:

// gasket.js

+ import pluginExpress from '@gasket/plugin-express';

export default makeGasket({
  plugins: [
+   pluginExpress
  ]
});

Configuration

All the configurations for the plugin are added under express in the config:

Example configuration

export default makeGasket({
  plugins: [
    pluginExpress
  ],
  express: {
    compression: false,
    trustProxy: true
  }
});

Route Definition

Routes can be defined in a in-app plugin in the plugins directory. The plugin will hook the express lifecycle to add the routes to the express app.

// plugins/routes-plugin.js
export default {
  name: 'routes-plugin',
  hooks: {
    express: async function (gasket, app) {
      app.get('/hello', (req, res) => {
        res.send('Hello World!');
      });
    }
  }
};

Lifecycles

express

Executed after the middleware event for when you need full control over the express instance.

export default {
  name: 'sample-plugin',
  hooks: {
    /**
    * Update Express app instance
    *
    * @param {Gasket} gasket The Gasket API
    * @param {Express} express Express app instance
    * @returns {function|function[]} middleware(s)
    */
    express: async function (gasket, express) {
    }
  }
};

errorMiddleware

Executed after the express event. All middleware functions returned from this hook will be applied to Express.

export default {
  name: 'sample-plugin',
  hooks: {
    /**
    * Add Express error middlewares
    *
    * @param {Gasket} gasket The Gasket API
    * @returns {function|function[]} error middleware(s)
    */
    errorMiddleware: function (gasket) {
    }
  }
};

How it works

This plugins hooks the createServers lifecycles from @gasket/plugin-https.

License

MIT

7.3.1

9 months ago

7.3.0

10 months ago

7.1.0-next.1

1 year ago

7.1.0-next.0

1 year ago

7.1.0-next.7

1 year ago

7.1.0-next.6

1 year ago

7.4.0

7 months ago

7.1.0-next.3

1 year ago

7.1.0-next.2

1 year ago

7.1.0-next.5

1 year ago

7.1.0-next.4

1 year ago

7.0.12

1 year ago

7.0.10

1 year ago

7.0.11

1 year ago

7.0.14

1 year ago

7.0.15

1 year ago

6.48.0

1 year ago

7.1.0-canary.3

1 year ago

7.1.0-canary.1

1 year ago

7.1.0-canary.2

1 year ago

7.0.8

1 year ago

7.0.9

1 year ago

7.1.4

11 months ago

7.1.3

11 months ago

7.1.2

12 months ago

7.1.1

1 year ago

7.1.0

1 year ago

7.2.3

10 months ago

7.2.2

10 months ago

7.2.1

11 months ago

7.2.0

11 months ago

7.3.5

7 months ago

7.3.4

8 months ago

7.3.3

9 months ago

7.3.2

9 months ago

7.0.6

1 year ago

7.0.4

1 year ago

7.0.0

1 year ago

7.0.1

1 year ago

6.47.4

1 year ago

6.47.5

1 year ago

7.0.0-next.69

1 year ago

7.0.0-next.70

1 year ago

7.0.0-next.67

1 year ago

7.0.0-next.68

1 year ago

6.47.3

1 year ago

7.0.0-next.66

1 year ago

7.0.0-next.65

1 year ago

7.0.0-next.64

1 year ago

7.0.0-next.63

1 year ago

7.0.0-next.62

1 year ago

7.0.0-next.61

1 year ago

6.47.1

2 years ago

7.0.0-next.44

1 year ago

7.0.0-next.45

1 year ago

7.0.0-next.46

1 year ago

7.0.0-next.47

1 year ago

7.0.0-next.48

1 year ago

7.0.0-next.49

1 year ago

7.0.0-next.40

1 year ago

7.0.0-next.41

1 year ago

7.0.0-next.42

1 year ago

7.0.0-next.54

1 year ago

7.0.0-next.55

1 year ago

7.0.0-next.56

1 year ago

7.0.0-next.57

1 year ago

7.0.0-next.58

1 year ago

7.0.0-next.59

1 year ago

7.0.0-next.50

1 year ago

7.0.0-next.51

1 year ago

7.2.0-canary.20

2 years ago

7.0.0-next.52

1 year ago

7.0.0-next.53

1 year ago

7.0.0-next.29

2 years ago

7.2.0-canary.0

2 years ago

7.2.0-canary.1

2 years ago

7.0.0-next.28

2 years ago

7.0.0-next.32

2 years ago

7.0.0-next.33

2 years ago

7.0.0-next.34

2 years ago

7.0.0-next.37

2 years ago

7.0.0-next.38

1 year ago

7.0.0-next.39

1 year ago

7.0.1-canary.12

2 years ago

7.0.1-canary.11

2 years ago

7.0.0-next.30

2 years ago

7.0.1-canary.10

2 years ago

7.0.0-next.31

2 years ago

7.3.0-canary.2

2 years ago

7.3.0-canary.1

2 years ago

7.3.0-canary.0

2 years ago

7.3.0-canary.4

2 years ago

7.3.0-canary.3

2 years ago

7.0.0-next.60

1 year ago

7.0.1-canary.0

2 years ago

7.0.0-next.26

2 years ago

7.0.0-next.27

2 years ago

7.0.0-next.25

2 years ago

7.0.0-next.22

2 years ago

7.0.0-next.23

2 years ago

7.0.0-next.21

2 years ago

7.0.0-next.9

2 years ago

7.0.0-next.10

2 years ago

7.0.0-next.7

2 years ago

7.0.0-next.11

2 years ago

7.0.0-next.8

2 years ago

7.0.0-next.12

2 years ago

7.0.0-next.13

2 years ago

7.0.0-next.6

2 years ago

7.0.0-next.20

2 years ago

7.0.0-next.5

2 years ago

6.46.8

2 years ago

7.0.0-next.4

2 years ago

7.0.0-next.3

2 years ago

7.0.0-next.2

2 years ago

7.0.0-next.1

2 years ago

7.0.0-next.0

2 years ago

6.46.7

2 years ago

7.0.0-cli.7

2 years ago

7.0.0-cli.6

2 years ago

6.46.5

2 years ago

6.46.1-cli.0

2 years ago

7.0.0-cli.5

2 years ago

7.0.0-cli.4

2 years ago

7.0.0-cli.1

2 years ago

7.0.0-cli.0

2 years ago

7.0.0-cli.3

2 years ago

7.0.0-cli.2

2 years ago

6.46.4

2 years ago

6.46.3-cli.0

2 years ago

6.46.2

2 years ago

7.0.0-canary.1

2 years ago

6.46.2-esm.0

2 years ago

6.46.0

2 years ago

6.45.2

2 years ago

6.45.0

2 years ago

6.44.0

2 years ago

6.43.0

2 years ago

6.41.2

2 years ago

6.41.1

2 years ago

6.42.0-canary.1

2 years ago

6.42.0-canary.2

2 years ago

6.42.0-canary.0

2 years ago

6.39.3

3 years ago

6.38.8

3 years ago

6.39.0

3 years ago

6.38.5

3 years ago

6.38.1

3 years ago

6.36.1

3 years ago

6.38.0

3 years ago

6.34.6

3 years ago

6.35.0

3 years ago

6.36.0

3 years ago

6.34.3

3 years ago

6.34.4

3 years ago

6.34.2

3 years ago

6.33.0

3 years ago

6.33.1

3 years ago

6.26.1

3 years ago

6.28.0

3 years ago

6.21.0

4 years ago

6.24.2

4 years ago

6.24.0

4 years ago

6.20.4

4 years ago

6.20.3

4 years ago

6.20.2

4 years ago

6.19.0

4 years ago

6.17.0

4 years ago

6.17.1

4 years ago

6.15.2

4 years ago

6.10.1

4 years ago

6.10.0

4 years ago

6.14.0

4 years ago

6.5.0

4 years ago

6.0.12

5 years ago

6.0.5

5 years ago

6.0.0

5 years ago

6.0.0-canary.13

5 years ago

6.0.0-canary.2

5 years ago

5.9.0

5 years ago

6.0.0-canary.0

5 years ago

5.6.0

5 years ago

5.1.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

5.0.0-canary.4

6 years ago

5.0.0-canary.3

6 years ago

5.0.0-canary.2

6 years ago

5.0.0-canary.1

6 years ago

5.0.0-canary.0

6 years ago