Skip to content

Commit 54e3d9d

Browse files
Copilothotlong
andcommitted
fix: address code review comments - remove unused imports, fix 304 response, add fail-fast for string handlers
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 14d984b commit 54e3d9d

4 files changed

Lines changed: 15 additions & 16 deletions

File tree

examples/rest-server-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* generate RESTful CRUD endpoints for your ObjectStack application.
66
*/
77

8-
import { RestServer, HttpServer } from '@objectstack/runtime';
8+
import { RestServer } from '@objectstack/runtime';
99
import type { IProtocolProvider } from '@objectstack/runtime';
1010

1111
/**

packages/runtime/src/http-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IHttpServer, IHttpRequest, IHttpResponse, RouteHandler, Middleware } from '@objectstack/core';
1+
import { IHttpServer, RouteHandler, Middleware } from '@objectstack/core';
22

33
/**
44
* HttpServer - Unified HTTP Server Abstraction

packages/runtime/src/rest-server.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { IHttpServer, RouteHandler } from '@objectstack/core';
1+
import { IHttpServer } from '@objectstack/core';
22
import { RouteManager } from './route-manager';
3-
import { RestServerConfig, CrudOperation } from '@objectstack/spec/api';
4-
import { ObjectStackProtocol } from '@objectstack/spec/api';
3+
import { RestServerConfig } from '@objectstack/spec/api';
54

65
/**
76
* RestServer
@@ -221,7 +220,7 @@ export class RestServer {
221220
});
222221

223222
if (result.notModified) {
224-
res.status(304).json({});
223+
res.status(304).send();
225224
return;
226225
}
227226

packages/runtime/src/route-manager.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,16 @@ export class RouteManager {
6161
* @param entry - Route entry with method, path, handler, and metadata
6262
*/
6363
register(entry: Omit<RouteEntry, 'handler'> & { handler: RouteHandler | string }): void {
64-
const handler = typeof entry.handler === 'string'
65-
? this.resolveHandler(entry.handler)
66-
: entry.handler;
64+
// Validate handler type - string handlers not yet supported
65+
if (typeof entry.handler === 'string') {
66+
throw new Error(
67+
`String-based route handlers are not supported yet. ` +
68+
`Received handler identifier "${entry.handler}". ` +
69+
`Please provide a RouteHandler function instead.`
70+
);
71+
}
72+
73+
const handler: RouteHandler = entry.handler;
6774

6875
const routeEntry: RouteEntry = {
6976
method: entry.method,
@@ -200,13 +207,6 @@ export class RouteManager {
200207
throw new Error(`Unsupported HTTP method: ${method}`);
201208
}
202209
}
203-
204-
/**
205-
* Resolve handler by name (placeholder for future handler registry)
206-
*/
207-
private resolveHandler(handlerName: string): RouteHandler {
208-
throw new Error(`Handler resolution not implemented: ${handlerName}`);
209-
}
210210
}
211211

212212
/**

0 commit comments

Comments
 (0)