@hot-updater/server 0.21.14 → 0.22.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/dist/handler.cjs CHANGED
@@ -3,10 +3,8 @@ let rou3 = require("rou3");
3
3
  rou3 = require_rolldown_runtime.__toESM(rou3);
4
4
 
5
5
  //#region src/handler.ts
6
- const handleUpdate = async (_params, request, api) => {
7
- const body = await request.json();
8
- const updateInfo = await api.getAppUpdateInfo(body);
9
- return new Response(JSON.stringify(updateInfo), {
6
+ const handleVersion = async () => {
7
+ return new Response(JSON.stringify({ version: "0.22.0" }), {
10
8
  status: 200,
11
9
  headers: { "Content-Type": "application/json" }
12
10
  });
@@ -93,7 +91,7 @@ const handleGetChannels = async (_params, _request, api) => {
93
91
  });
94
92
  };
95
93
  const routes = {
96
- update: handleUpdate,
94
+ version: handleVersion,
97
95
  fingerprintUpdate: handleFingerprintUpdate,
98
96
  appVersionUpdate: handleAppVersionUpdate,
99
97
  getBundle: handleGetBundle,
@@ -110,14 +108,14 @@ const routes = {
110
108
  function createHandler(api, options = {}) {
111
109
  const basePath = options.basePath ?? "/api";
112
110
  const router = (0, rou3.createRouter)();
113
- (0, rou3.addRoute)(router, "POST", "/update", "update");
111
+ (0, rou3.addRoute)(router, "GET", "/version", "version");
114
112
  (0, rou3.addRoute)(router, "GET", "/fingerprint/:platform/:fingerprintHash/:channel/:minBundleId/:bundleId", "fingerprintUpdate");
115
113
  (0, rou3.addRoute)(router, "GET", "/app-version/:platform/:appVersion/:channel/:minBundleId/:bundleId", "appVersionUpdate");
116
- (0, rou3.addRoute)(router, "GET", "/bundles/:id", "getBundle");
117
- (0, rou3.addRoute)(router, "GET", "/bundles", "getBundles");
118
- (0, rou3.addRoute)(router, "POST", "/bundles", "createBundles");
119
- (0, rou3.addRoute)(router, "DELETE", "/bundles/:id", "deleteBundle");
120
- (0, rou3.addRoute)(router, "GET", "/channels", "getChannels");
114
+ (0, rou3.addRoute)(router, "GET", "/api/bundles/channels", "getChannels");
115
+ (0, rou3.addRoute)(router, "GET", "/api/bundles/:id", "getBundle");
116
+ (0, rou3.addRoute)(router, "GET", "/api/bundles", "getBundles");
117
+ (0, rou3.addRoute)(router, "POST", "/api/bundles", "createBundles");
118
+ (0, rou3.addRoute)(router, "DELETE", "/api/bundles/:id", "deleteBundle");
121
119
  return async (request) => {
122
120
  try {
123
121
  const path = new URL(request.url).pathname;
package/dist/handler.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import { addRoute, createRouter, findRoute } from "rou3";
2
2
 
3
3
  //#region src/handler.ts
4
- const handleUpdate = async (_params, request, api) => {
5
- const body = await request.json();
6
- const updateInfo = await api.getAppUpdateInfo(body);
7
- return new Response(JSON.stringify(updateInfo), {
4
+ const handleVersion = async () => {
5
+ return new Response(JSON.stringify({ version: "0.22.0" }), {
8
6
  status: 200,
9
7
  headers: { "Content-Type": "application/json" }
10
8
  });
@@ -91,7 +89,7 @@ const handleGetChannels = async (_params, _request, api) => {
91
89
  });
92
90
  };
93
91
  const routes = {
94
- update: handleUpdate,
92
+ version: handleVersion,
95
93
  fingerprintUpdate: handleFingerprintUpdate,
96
94
  appVersionUpdate: handleAppVersionUpdate,
97
95
  getBundle: handleGetBundle,
@@ -108,14 +106,14 @@ const routes = {
108
106
  function createHandler(api, options = {}) {
109
107
  const basePath = options.basePath ?? "/api";
110
108
  const router = createRouter();
111
- addRoute(router, "POST", "/update", "update");
109
+ addRoute(router, "GET", "/version", "version");
112
110
  addRoute(router, "GET", "/fingerprint/:platform/:fingerprintHash/:channel/:minBundleId/:bundleId", "fingerprintUpdate");
113
111
  addRoute(router, "GET", "/app-version/:platform/:appVersion/:channel/:minBundleId/:bundleId", "appVersionUpdate");
114
- addRoute(router, "GET", "/bundles/:id", "getBundle");
115
- addRoute(router, "GET", "/bundles", "getBundles");
116
- addRoute(router, "POST", "/bundles", "createBundles");
117
- addRoute(router, "DELETE", "/bundles/:id", "deleteBundle");
118
- addRoute(router, "GET", "/channels", "getChannels");
112
+ addRoute(router, "GET", "/api/bundles/channels", "getChannels");
113
+ addRoute(router, "GET", "/api/bundles/:id", "getBundle");
114
+ addRoute(router, "GET", "/api/bundles", "getBundles");
115
+ addRoute(router, "POST", "/api/bundles", "createBundles");
116
+ addRoute(router, "DELETE", "/api/bundles/:id", "deleteBundle");
119
117
  return async (request) => {
120
118
  try {
121
119
  const path = new URL(request.url).pathname;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/server",
3
- "version": "0.21.14",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -46,12 +46,12 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "fumadb": "0.2.0",
49
+ "fumadb": "0.2.1",
50
50
  "rou3": "0.7.9",
51
51
  "semver": "^7.7.2",
52
- "@hot-updater/core": "0.21.14",
53
- "@hot-updater/plugin-core": "0.21.14",
54
- "@hot-updater/js": "0.21.14"
52
+ "@hot-updater/core": "0.22.0",
53
+ "@hot-updater/plugin-core": "0.22.0",
54
+ "@hot-updater/js": "0.22.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@electric-sql/pglite": "^0.2.17",
@@ -62,12 +62,12 @@
62
62
  "kysely-pglite-dialect": "^1.2.0",
63
63
  "msw": "^2.7.0",
64
64
  "uuidv7": "^1.0.2",
65
- "@hot-updater/cloudflare": "0.21.14",
66
- "@hot-updater/aws": "0.21.14",
67
- "@hot-updater/firebase": "0.21.14",
68
- "@hot-updater/standalone": "0.21.14",
69
- "@hot-updater/supabase": "0.21.14",
70
- "@hot-updater/test-utils": "0.21.14"
65
+ "@hot-updater/aws": "0.22.0",
66
+ "@hot-updater/cloudflare": "0.22.0",
67
+ "@hot-updater/firebase": "0.22.0",
68
+ "@hot-updater/standalone": "0.22.0",
69
+ "@hot-updater/supabase": "0.22.0",
70
+ "@hot-updater/test-utils": "0.22.0"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "tsdown",
@@ -62,16 +62,16 @@ beforeAll(async () => {
62
62
 
63
63
  server.use(
64
64
  // Specific routes
65
- http.get(`${baseUrl}/hot-updater/bundles`, ({ request }) =>
65
+ http.get(`${baseUrl}/hot-updater/api/bundles`, ({ request }) =>
66
66
  handleRequest(request),
67
67
  ),
68
- http.get(`${baseUrl}/hot-updater/bundles/:id`, ({ request }) =>
68
+ http.get(`${baseUrl}/hot-updater/api/bundles/:id`, ({ request }) =>
69
69
  handleRequest(request),
70
70
  ),
71
- http.post(`${baseUrl}/hot-updater/bundles`, ({ request }) =>
71
+ http.post(`${baseUrl}/hot-updater/api/bundles`, ({ request }) =>
72
72
  handleRequest(request),
73
73
  ),
74
- http.delete(`${baseUrl}/hot-updater/bundles/:id`, ({ request }) =>
74
+ http.delete(`${baseUrl}/hot-updater/api/bundles/:id`, ({ request }) =>
75
75
  handleRequest(request),
76
76
  ),
77
77
  );
@@ -121,9 +121,12 @@ describe("Handler <-> Standalone Repository Integration", () => {
121
121
  await repo.commitBundle(); // Triggers actual commit
122
122
 
123
123
  // Verify via handler that bundle was created
124
- const request = new Request(`${baseUrl}/hot-updater/bundles/${bundleId}`, {
125
- method: "GET",
126
- });
124
+ const request = new Request(
125
+ `${baseUrl}/hot-updater/api/bundles/${bundleId}`,
126
+ {
127
+ method: "GET",
128
+ },
129
+ );
127
130
 
128
131
  const response = await api.handler(request);
129
132
  expect(response.status).toBe(200);
package/src/handler.ts CHANGED
@@ -7,6 +7,8 @@ import type {
7
7
  import { addRoute, createRouter, findRoute } from "rou3";
8
8
  import type { PaginationInfo } from "./types";
9
9
 
10
+ declare const __VERSION__: string;
11
+
10
12
  // Narrow API surface needed by the handler to avoid circular types
11
13
  export interface HandlerAPI {
12
14
  getAppUpdateInfo: (
@@ -38,13 +40,8 @@ type RouteHandler = (
38
40
  ) => Promise<Response>;
39
41
 
40
42
  // Route handlers
41
- const handleUpdate: RouteHandler = async (_params, request, api) => {
42
- const body = (await request.json()) as
43
- | AppVersionGetBundlesArgs
44
- | FingerprintGetBundlesArgs;
45
- const updateInfo = await api.getAppUpdateInfo(body);
46
-
47
- return new Response(JSON.stringify(updateInfo), {
43
+ const handleVersion: RouteHandler = async () => {
44
+ return new Response(JSON.stringify({ version: __VERSION__ }), {
48
45
  status: 200,
49
46
  headers: { "Content-Type": "application/json" },
50
47
  });
@@ -154,7 +151,7 @@ const handleGetChannels: RouteHandler = async (_params, _request, api) => {
154
151
 
155
152
  // Route handlers map
156
153
  const routes: Record<string, RouteHandler> = {
157
- update: handleUpdate,
154
+ version: handleVersion,
158
155
  fingerprintUpdate: handleFingerprintUpdate,
159
156
  appVersionUpdate: handleAppVersionUpdate,
160
157
  getBundle: handleGetBundle,
@@ -179,7 +176,7 @@ export function createHandler(
179
176
  const router = createRouter();
180
177
 
181
178
  // Register routes
182
- addRoute(router, "POST", "/update", "update");
179
+ addRoute(router, "GET", "/version", "version");
183
180
  addRoute(
184
181
  router,
185
182
  "GET",
@@ -192,11 +189,11 @@ export function createHandler(
192
189
  "/app-version/:platform/:appVersion/:channel/:minBundleId/:bundleId",
193
190
  "appVersionUpdate",
194
191
  );
195
- addRoute(router, "GET", "/bundles/:id", "getBundle");
196
- addRoute(router, "GET", "/bundles", "getBundles");
197
- addRoute(router, "POST", "/bundles", "createBundles");
198
- addRoute(router, "DELETE", "/bundles/:id", "deleteBundle");
199
- addRoute(router, "GET", "/channels", "getChannels");
192
+ addRoute(router, "GET", "/api/bundles/channels", "getChannels");
193
+ addRoute(router, "GET", "/api/bundles/:id", "getBundle");
194
+ addRoute(router, "GET", "/api/bundles", "getBundles");
195
+ addRoute(router, "POST", "/api/bundles", "createBundles");
196
+ addRoute(router, "DELETE", "/api/bundles/:id", "deleteBundle");
200
197
 
201
198
  return async (request: Request): Promise<Response> => {
202
199
  try {