Skip to content

Commit 1701a67

Browse files
Copilothotlong
andcommitted
fix: resolve TypeScript build errors in sveltekit, express, and nextjs adapters
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent d458ba5 commit 1701a67

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

packages/adapters/express/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface ExpressAdapterOptions {
1212
* Auth service interface with handleRequest method
1313
*/
1414
interface AuthService {
15-
handleRequest(request: Request): Promise<globalThis.Response>;
15+
handleRequest(request: globalThis.Request): Promise<globalThis.Response>;
1616
}
1717

1818
/**

packages/adapters/nextjs/src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,15 @@ export interface ServerActionResult<T = any> {
199199
*/
200200
export function createServerActions(options: NextAdapterOptions) {
201201
const dispatcher = new HttpDispatcher(options.kernel);
202+
const emptyContext = { request: null };
202203

203204
return {
204205
/**
205206
* Query records from an object
206207
*/
207208
async query(objectName: string, params?: Record<string, any>): Promise<ServerActionResult> {
208209
try {
209-
const result = await dispatcher.handleData(`/${objectName}`, 'GET', {}, params || {}, {});
210+
const result = await dispatcher.handleData(`/${objectName}`, 'GET', {}, params || {}, emptyContext);
210211
if (result.handled && result.response) {
211212
return { success: true, data: result.response.body };
212213
}
@@ -221,7 +222,7 @@ export function createServerActions(options: NextAdapterOptions) {
221222
*/
222223
async getById(objectName: string, id: string): Promise<ServerActionResult> {
223224
try {
224-
const result = await dispatcher.handleData(`/${objectName}/${id}`, 'GET', {}, {}, {});
225+
const result = await dispatcher.handleData(`/${objectName}/${id}`, 'GET', {}, {}, emptyContext);
225226
if (result.handled && result.response) {
226227
return { success: true, data: result.response.body };
227228
}
@@ -236,7 +237,7 @@ export function createServerActions(options: NextAdapterOptions) {
236237
*/
237238
async create(objectName: string, data: Record<string, any>): Promise<ServerActionResult> {
238239
try {
239-
const result = await dispatcher.handleData(`/${objectName}`, 'POST', data, {}, {});
240+
const result = await dispatcher.handleData(`/${objectName}`, 'POST', data, {}, emptyContext);
240241
if (result.handled && result.response) {
241242
return { success: true, data: result.response.body };
242243
}
@@ -251,7 +252,7 @@ export function createServerActions(options: NextAdapterOptions) {
251252
*/
252253
async update(objectName: string, id: string, data: Record<string, any>): Promise<ServerActionResult> {
253254
try {
254-
const result = await dispatcher.handleData(`/${objectName}/${id}`, 'PATCH', data, {}, {});
255+
const result = await dispatcher.handleData(`/${objectName}/${id}`, 'PATCH', data, {}, emptyContext);
255256
if (result.handled && result.response) {
256257
return { success: true, data: result.response.body };
257258
}
@@ -266,7 +267,7 @@ export function createServerActions(options: NextAdapterOptions) {
266267
*/
267268
async remove(objectName: string, id: string): Promise<ServerActionResult> {
268269
try {
269-
const result = await dispatcher.handleData(`/${objectName}/${id}`, 'DELETE', {}, {}, {});
270+
const result = await dispatcher.handleData(`/${objectName}/${id}`, 'DELETE', {}, {}, emptyContext);
270271
if (result.handled && result.response) {
271272
return { success: true, data: result.response.body };
272273
}
@@ -281,7 +282,7 @@ export function createServerActions(options: NextAdapterOptions) {
281282
*/
282283
async getMetadata(path?: string): Promise<ServerActionResult> {
283284
try {
284-
const result = await dispatcher.handleMetadata(path || '', {}, 'GET');
285+
const result = await dispatcher.handleMetadata(path || '', emptyContext, 'GET');
285286
if (result.handled && result.response) {
286287
return { success: true, data: result.response.body };
287288
}

packages/adapters/sveltekit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function createRequestHandler(options: SvelteKitAdapterOptions) {
127127

128128
// --- GraphQL ---
129129
if (segments[0] === 'graphql' && method === 'POST') {
130-
const body = await request.json();
130+
const body = await request.json() as { query: string; variables?: any };
131131
const result = await dispatcher.handleGraphQL(body, { request });
132132
return new Response(JSON.stringify(result), {
133133
status: 200,

0 commit comments

Comments
 (0)