@remit/backend 0.0.31 → 0.0.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/backend",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "Remit Mail Inspector API backend",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -130,11 +130,14 @@ describe("GET /system/update", () => {
130
130
  assert.deepEqual(result, okState);
131
131
  });
132
132
 
133
- it("returns a disabled, empty resource when no state file exists", async () => {
133
+ it("reports an unknown version, not its own process env, when no state file exists", async () => {
134
+ // The updater owns the running version and writes it into state.json; with
135
+ // no state file the backend has nothing authoritative, so it says unknown
136
+ // rather than surfacing REMIT_TAG, which drifts from the real running tag.
134
137
  const result = await getUpdate(buildEvent(USER));
135
138
 
136
139
  assert.deepEqual(result, {
137
- currentVersion: "v1.4.1",
140
+ currentVersion: "unknown",
138
141
  check: { status: "disabled" },
139
142
  run: null,
140
143
  });
@@ -24,7 +24,17 @@ const controlDir = (): string =>
24
24
  const manifestUrl = (): string | undefined =>
25
25
  process.env.REMIT_UPDATE_MANIFEST_URL;
26
26
 
27
- const currentVersion = (): string => process.env.REMIT_TAG ?? "unknown";
27
+ /**
28
+ * The running version is a fact the updater owns: it reads the tag from `.env`
29
+ * and writes it into `state.json`, which is the only honest source across an
30
+ * update that rewrites that tag underneath a long-lived backend process. When no
31
+ * state file exists yet the backend has nothing authoritative to report, so it
32
+ * reports the version as unknown rather than fabricating one from its own
33
+ * process environment — a value captured at container start that drifts from the
34
+ * real running tag the moment an update lands. The first updater check writes a
35
+ * real `currentVersion` within seconds of the stack coming up.
36
+ */
37
+ const UNKNOWN_VERSION = "unknown";
28
38
 
29
39
  const notFound = (): APIGatewayProxyResult => ({
30
40
  statusCode: 404,
@@ -65,7 +75,7 @@ const readState = (): SystemUpdateResponse | null => {
65
75
  };
66
76
 
67
77
  const emptyResource = (): SystemUpdateResponse => ({
68
- currentVersion: currentVersion(),
78
+ currentVersion: UNKNOWN_VERSION,
69
79
  check: { status: "disabled" },
70
80
  run: null,
71
81
  });
@@ -115,7 +125,7 @@ const requestedResource = (
115
125
  targetVersion: string,
116
126
  requestedAt: string,
117
127
  ): SystemUpdateResponse => {
118
- const from = state?.currentVersion ?? currentVersion();
128
+ const from = state?.currentVersion ?? UNKNOWN_VERSION;
119
129
  return {
120
130
  currentVersion: from,
121
131
  check: state?.check ?? { status: "disabled" },