@eik/service 2.3.2 → 3.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [3.0.0](https://github.com/eik-lib/service/compare/v2.3.2...v3.0.0) (2024-08-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * let compression finish before adding routes ([#592](https://github.com/eik-lib/service/issues/592)) ([f3796eb](https://github.com/eik-lib/service/commit/f3796ebfcb6d7c350e0eeae3578f329c6ec1f49e))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * requires `await` when registering the eik plugin
12
+ with fastify (`await fastify.register(service.api())`).
13
+
1
14
  ## [2.3.2](https://github.com/eik-lib/service/compare/v2.3.1...v2.3.2) (2024-08-19)
2
15
 
3
16
 
package/bin/eik-server.js CHANGED
@@ -12,7 +12,7 @@ const app = Fastify({
12
12
  http2: eik.config.get('http.http2'),
13
13
  });
14
14
 
15
- app.register(eik.api());
15
+ await app.register(eik.api());
16
16
 
17
17
  try {
18
18
  await eik.health();
package/lib/main.js CHANGED
@@ -201,7 +201,8 @@ const EikService = class EikService {
201
201
  }
202
202
 
203
203
  api() {
204
- return (app, options, done) => {
204
+ /** @param {import('fastify').FastifyInstance} app */
205
+ return async (app) => {
205
206
  if (!app.initialConfig.ignoreTrailingSlash) {
206
207
  this.logger.warn(
207
208
  'Fastify is configured with "ignoreTrailingSlash" set to "false". Its adviced to set "ignoreTrailingSlash" to "true"',
@@ -233,6 +234,7 @@ const EikService = class EikService {
233
234
  });
234
235
 
235
236
  const authOptions = {
237
+ // @ts-expect-error We decorate it above
236
238
  preValidation: [app.authenticate],
237
239
  };
238
240
 
@@ -246,7 +248,7 @@ const EikService = class EikService {
246
248
  app.addContentTypeParser('multipart', setMultipart);
247
249
 
248
250
  // Compression
249
- app.register(compression, {
251
+ await app.register(compression, {
250
252
  global: config.get('compression.global'),
251
253
  });
252
254
 
@@ -905,8 +907,6 @@ const EikService = class EikService {
905
907
  authOptions,
906
908
  aliasDelRoute,
907
909
  );
908
-
909
- done();
910
910
  };
911
911
  }
912
912
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/service",
3
- "version": "2.3.2",
3
+ "version": "3.0.0",
4
4
  "description": "Eik REST API as a standalone HTTP service",
5
5
  "type": "module",
6
6
  "main": "./lib/main.js",
package/types/main.d.ts CHANGED
@@ -599,7 +599,7 @@ declare const EikService: {
599
599
  logger: pino.Logger<never>;
600
600
  sink: import("@eik/sink").default;
601
601
  health(): Promise<void>;
602
- api(): (app: any, options: any, done: any) => void;
602
+ api(): (app: import("fastify").FastifyInstance) => Promise<void>;
603
603
  };
604
604
  };
605
605
  import { PassThrough } from 'stream';