@fastify/express 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,4 +14,5 @@ jobs:
14
14
  test:
15
15
  uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
16
16
  with:
17
+ lint: true
17
18
  license-check: true
package/.taprc ADDED
@@ -0,0 +1 @@
1
+ --no-coverage
package/index.js CHANGED
@@ -4,7 +4,7 @@ const fp = require('fastify-plugin')
4
4
  const Express = require('express')
5
5
  const kMiddlewares = Symbol('fastify-express-middlewares')
6
6
 
7
- function expressPlugin (fastify, options, next) {
7
+ function fastifyExpress (fastify, options, next) {
8
8
  const {
9
9
  expressHook = 'onRequest'
10
10
  } = options
@@ -87,7 +87,9 @@ function expressPlugin (fastify, options, next) {
87
87
  next()
88
88
  }
89
89
 
90
- module.exports = fp(expressPlugin, {
90
+ module.exports = fp(fastifyExpress, {
91
91
  fastify: '4.x',
92
92
  name: '@fastify/express'
93
93
  })
94
+ module.exports.default = fastifyExpress
95
+ module.exports.fastifyExpress = fastifyExpress
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@fastify/express",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Express compatibility layer for Fastify",
5
5
  "main": "index.js",
6
- "types": "index.d.ts",
6
+ "types": "types/index.d.ts",
7
+ "scripts": {
8
+ "lint": "standard",
9
+ "test": "npm run test:unit && npm run test:typescript",
10
+ "test:unit": "tap",
11
+ "test:typescript": "tsd"
12
+ },
7
13
  "repository": {
8
14
  "type": "git",
9
15
  "url": "git+https://github.com/fastify/fastify-express.git"
@@ -22,12 +28,12 @@
22
28
  },
23
29
  "homepage": "https://github.com/fastify/fastify-express#readme",
24
30
  "devDependencies": {
31
+ "@fastify/formbody": "^7.0.1",
25
32
  "@types/express": "^4.17.1",
26
33
  "@types/node": "*",
27
34
  "body-parser": "^1.20.0",
28
35
  "cors": "^2.8.5",
29
36
  "fastify": "^4.0.0-rc.3",
30
- "@fastify/formbody": "^7.0.1",
31
37
  "helmet": "^6.0.0",
32
38
  "passport": "^0.6.0",
33
39
  "passport-http-bearer": "^1.0.1",
@@ -46,8 +52,5 @@
46
52
  },
47
53
  "publishConfig": {
48
54
  "access": "public"
49
- },
50
- "scripts": {
51
- "test": "standard && tap --no-coverage test/*.test.js && tsd"
52
55
  }
53
- }
56
+ }
@@ -0,0 +1,31 @@
1
+ import { Application } from 'express'
2
+ import { FastifyPluginCallback } from 'fastify'
3
+
4
+ declare module 'fastify' {
5
+ interface FastifyInstance {
6
+ /**
7
+ * Express middleware function
8
+ */
9
+ use: Application['use']
10
+
11
+ /**
12
+ * Express application instance
13
+ */
14
+ express: Application
15
+ }
16
+ }
17
+
18
+ type FastifyExpress = FastifyPluginCallback<fastifyExpress.FastifyExpressOptions>
19
+
20
+ declare namespace fastifyExpress {
21
+
22
+ export interface FastifyExpressOptions {
23
+ expressHook?: string;
24
+ }
25
+
26
+ export const fastifyExpress: FastifyExpress
27
+ export { fastifyExpress as default }
28
+ }
29
+
30
+ declare function fastifyExpress(...params: Parameters<FastifyExpress>): ReturnType<FastifyExpress>
31
+ export = fastifyExpress
@@ -0,0 +1,19 @@
1
+ import Fastify from 'fastify'
2
+ import fastifyExpress from '..'
3
+ import { expectType } from "tsd"
4
+ import { Application } from 'express'
5
+
6
+ const app = Fastify()
7
+
8
+ app.register(fastifyExpress)
9
+ app.register(fastifyExpress, {
10
+ expressHook: 'onRequest'
11
+ })
12
+
13
+ expectType<Application>(app.express)
14
+
15
+ app.express.disable('x-powered-by')
16
+
17
+ app.use('/world', (_req, res) => {
18
+ res.sendStatus(200)
19
+ })
package/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { Application } from 'express'
2
- import { FastifyPluginCallback } from 'fastify'
3
-
4
- declare module 'fastify' {
5
- interface FastifyInstance {
6
- /**
7
- * Express middleware function
8
- */
9
- use: Application['use']
10
-
11
- /**
12
- * Express application instance
13
- */
14
- express: Application
15
- }
16
- }
17
-
18
- declare const fastifyExpress: FastifyPluginCallback
19
-
20
- export default fastifyExpress
@@ -1,12 +0,0 @@
1
- import Fastify from 'fastify'
2
- import fastifyExpress from '../..'
3
-
4
- const app = Fastify()
5
-
6
- app.register(fastifyExpress)
7
-
8
- app.express.disable('x-powered-by')
9
-
10
- app.use('/world', (_req, res) => {
11
- res.sendStatus(200)
12
- })