@ovineko/spa-guard-fastify 0.0.1-alpha-27 → 0.0.1-alpha-29

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -3
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var handleBeaconRequest = async (params) => {
30
30
  } else {
31
31
  request.log.warn({ bodyType: typeof body }, logMessage("Unknown beacon format"));
32
32
  }
33
- return;
33
+ return false;
34
34
  }
35
35
  const logPayload = {
36
36
  ...beacon.appName && { appName: beacon.appName },
@@ -47,6 +47,7 @@ var handleBeaconRequest = async (params) => {
47
47
  } else {
48
48
  request.log.info(logPayload, logMessage("Beacon received"));
49
49
  }
50
+ return true;
50
51
  };
51
52
  var fastifySPAGuardPlugin = async (fastify, options) => {
52
53
  const { onBeacon, onUnknownBeacon, path } = options;
@@ -72,9 +73,14 @@ var fastifySPAGuardPlugin = async (fastify, options) => {
72
73
  return reply;
73
74
  }
74
75
  const body = parseStringBody(request.body);
75
- await handleBeaconRequest({ body, options: { onBeacon, onUnknownBeacon }, reply, request });
76
+ const success = await handleBeaconRequest({
77
+ body,
78
+ options: { onBeacon, onUnknownBeacon },
79
+ reply,
80
+ request
81
+ });
76
82
  if (!reply.sent) {
77
- return reply.status(200).send({ success: true });
83
+ return reply.status(success ? 200 : 400).send(success ? { success: true } : { error: "Invalid beacon format" });
78
84
  }
79
85
  return reply;
80
86
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovineko/spa-guard-fastify",
3
- "version": "0.0.1-alpha-27",
3
+ "version": "0.0.1-alpha-29",
4
4
  "description": "Fastify plugin for spa-guard beacon endpoint and HTML cache handler with ETag/304",
5
5
  "keywords": [
6
6
  "spa",
@@ -36,8 +36,8 @@
36
36
  "peerDependencies": {
37
37
  "fastify": "^5 || ^4",
38
38
  "fastify-plugin": "^5 || ^4",
39
- "@ovineko/spa-guard": "0.0.1-alpha-27",
40
- "@ovineko/spa-guard-node": "0.0.1-alpha-27"
39
+ "@ovineko/spa-guard": "0.0.1-alpha-29",
40
+ "@ovineko/spa-guard-node": "0.0.1-alpha-29"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=22.15.0"