Skip to content

Commit e1b48f4

Browse files
committed
prettier format
1 parent 69d9132 commit e1b48f4

File tree

30 files changed

+2750
-1653
lines changed

30 files changed

+2750
-1653
lines changed

packages/cli/src/actions/migrate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function runReset(prismaSchemaFile: string, options: ResetOptions) {
8686
'prisma migrate reset',
8787
` --schema "${prismaSchemaFile}"`,
8888
' --skip-generate',
89-
options.force ? ' --force' : ''
89+
options.force ? ' --force' : '',
9090
].join('');
9191

9292
await execPackage(cmd);
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { SchemaDef } from "@zenstackhq/orm/schema";
2-
import { log } from "../api/utils";
3-
import type { ApiHandler, LogConfig } from "../types";
1+
import type { SchemaDef } from '@zenstackhq/orm/schema';
2+
import { log } from '../api/utils';
3+
import type { ApiHandler, LogConfig } from '../types';
44

55
/**
66
* Options common to all adapters
@@ -13,5 +13,9 @@ export interface CommonAdapterOptions<Schema extends SchemaDef> {
1313
}
1414

1515
export function logInternalError(logger: LogConfig | undefined, err: unknown) {
16-
log(logger, 'error', `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? '\n' + err.stack : ''}`);
17-
}
16+
log(
17+
logger,
18+
'error',
19+
`An unhandled error occurred while processing the request: ${err}${err instanceof Error ? '\n' + err.stack : ''}`,
20+
);
21+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export { ZenStackFastifyPlugin, type FastifyPluginOptions } from './plugin';
2-

packages/server/src/adapter/fastify/plugin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { logInternalError, type CommonAdapterOptions } from '../common';
88
* Fastify plugin options
99
*/
1010
export interface FastifyPluginOptions<Schema extends SchemaDef> extends CommonAdapterOptions<Schema> {
11-
1211
/**
1312
* Url prefix, e.g.: /api
1413
*/
@@ -17,7 +16,10 @@ export interface FastifyPluginOptions<Schema extends SchemaDef> extends CommonAd
1716
/**
1817
* Callback for getting a ZenStackClient for the given request
1918
*/
20-
getClient: (request: FastifyRequest, reply: FastifyReply) => ClientContract<Schema> | Promise<ClientContract<Schema>>;
19+
getClient: (
20+
request: FastifyRequest,
21+
reply: FastifyReply,
22+
) => ClientContract<Schema> | Promise<ClientContract<Schema>>;
2123
}
2224

2325
/**

packages/server/src/adapter/nuxt/handler.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import type { ClientContract } from '@zenstackhq/orm';
22
import type { SchemaDef } from '@zenstackhq/orm/schema';
3-
import {
4-
H3Event,
5-
defineEventHandler,
6-
getQuery,
7-
getRouterParams,
8-
readBody,
9-
type EventHandlerRequest
10-
} from 'h3';
3+
import { H3Event, defineEventHandler, getQuery, getRouterParams, readBody, type EventHandlerRequest } from 'h3';
114
import { setResponseStatus } from 'nuxt/app';
125
import { logInternalError, type CommonAdapterOptions } from '../common';
136

packages/server/src/adapter/tanstack-start/handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { logInternalError } from '../common';
99
* @returns A TanStack Start server route handler
1010
*/
1111
export default function factory<Schema extends SchemaDef>(
12-
options: TanStackStartOptions<Schema>
12+
options: TanStackStartOptions<Schema>,
1313
): ({ request, params }: { request: Request; params: Record<string, string> }) => Promise<Response> {
1414
return async ({ request, params }: { request: Request; params: Record<string, string> }) => {
1515
const client = await options.getClient(request, params);
@@ -71,4 +71,3 @@ export default function factory<Schema extends SchemaDef>(
7171
}
7272
};
7373
}
74-

packages/server/src/adapter/tanstack-start/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ export interface TanStackStartOptions<Schema extends SchemaDef> extends CommonAd
1010
/**
1111
* Callback method for getting a ZenStackClient instance for the given request and params.
1212
*/
13-
getClient: (request: Request, params: Record<string, string>) => ClientContract<Schema> | Promise<ClientContract<Schema>> ;
13+
getClient: (
14+
request: Request,
15+
params: Record<string, string>,
16+
) => ClientContract<Schema> | Promise<ClientContract<Schema>>;
1417
}
1518

1619
/**
1720
* Creates a TanStack Start server route handler.
1821
* @see https://zenstack.dev/docs/reference/server-adapters/tanstack-start
1922
*/
20-
export function TanStackStartHandler<Schema extends SchemaDef>(options: TanStackStartOptions<Schema>): ReturnType<typeof Handler> {
23+
export function TanStackStartHandler<Schema extends SchemaDef>(
24+
options: TanStackStartOptions<Schema>,
25+
): ReturnType<typeof Handler> {
2126
return Handler(options);
2227
}
2328

2429
export default TanStackStartHandler;
25-

packages/server/test/adapter/elysia.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ describe('Elysia adapter tests - rpc handler', () => {
1111
const client = await createTestClient(schema);
1212

1313
const handler = await createElysiaApp(
14-
createElysiaHandler({ getClient: () => client, basePath: '/api', apiHandler: new RPCApiHandler({ schema: client.schema }) })
14+
createElysiaHandler({
15+
getClient: () => client,
16+
basePath: '/api',
17+
apiHandler: new RPCApiHandler({ schema: client.schema }),
18+
}),
1519
);
1620

1721
let r = await handler(makeRequest('GET', makeUrl('/api/post/findMany', { where: { id: { equals: '1' } } })));
@@ -31,7 +35,7 @@ describe('Elysia adapter tests - rpc handler', () => {
3135
],
3236
},
3337
},
34-
})
38+
}),
3539
);
3640
expect(r.status).toBe(201);
3741
expect((await unmarshal(r)).data).toMatchObject({
@@ -51,7 +55,7 @@ describe('Elysia adapter tests - rpc handler', () => {
5155
expect((await unmarshal(r)).data).toHaveLength(1);
5256

5357
r = await handler(
54-
makeRequest('PUT', '/api/user/update', { where: { id: 'user1' }, data: { email: '[email protected]' } })
58+
makeRequest('PUT', '/api/user/update', { where: { id: 'user1' }, data: { email: '[email protected]' } }),
5559
);
5660
expect(r.status).toBe(200);
5761
expect((await unmarshal(r)).data.email).toBe('[email protected]');
@@ -65,14 +69,14 @@ describe('Elysia adapter tests - rpc handler', () => {
6569
expect((await unmarshal(r)).data._sum.viewCount).toBe(3);
6670

6771
r = await handler(
68-
makeRequest('GET', makeUrl('/api/post/groupBy', { by: ['published'], _sum: { viewCount: true } }))
72+
makeRequest('GET', makeUrl('/api/post/groupBy', { by: ['published'], _sum: { viewCount: true } })),
6973
);
7074
expect(r.status).toBe(200);
7175
expect((await unmarshal(r)).data).toEqual(
7276
expect.arrayContaining([
7377
expect.objectContaining({ published: true, _sum: { viewCount: 1 } }),
7478
expect.objectContaining({ published: false, _sum: { viewCount: 2 } }),
75-
])
79+
]),
7680
);
7781

7882
r = await handler(makeRequest('DELETE', makeUrl('/api/user/deleteMany', { where: { id: 'user1' } })));
@@ -89,8 +93,8 @@ describe('Elysia adapter tests - rest handler', () => {
8993
createElysiaHandler({
9094
getClient: () => client,
9195
basePath: '/api',
92-
apiHandler: new RestApiHandler({schema: client.$schema, endpoint: 'http://localhost/api' }),
93-
})
96+
apiHandler: new RestApiHandler({ schema: client.$schema, endpoint: 'http://localhost/api' }),
97+
}),
9498
);
9599

96100
let r = await handler(makeRequest('GET', makeUrl('/api/post/1')));
@@ -102,7 +106,7 @@ describe('Elysia adapter tests - rest handler', () => {
102106
type: 'user',
103107
attributes: { id: 'user1', email: '[email protected]' },
104108
},
105-
})
109+
}),
106110
);
107111
expect(r.status).toBe(201);
108112
expect(await unmarshal(r)).toMatchObject({
@@ -129,7 +133,7 @@ describe('Elysia adapter tests - rest handler', () => {
129133
r = await handler(
130134
makeRequest('PUT', makeUrl('/api/user/user1'), {
131135
data: { type: 'user', attributes: { email: '[email protected]' } },
132-
})
136+
}),
133137
);
134138
expect(r.status).toBe(200);
135139
expect((await unmarshal(r)).data.attributes.email).toBe('[email protected]');

packages/server/test/adapter/fastify.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Fastify adapter tests - rpc handler', () => {
1313
app.register(ZenStackFastifyPlugin, {
1414
prefix: '/api',
1515
getClient: () => client,
16-
apiHandler: new RPCApiHandler({ schema: client.schema })
16+
apiHandler: new RPCApiHandler({ schema: client.schema }),
1717
});
1818

1919
let r = await app.inject({
@@ -49,7 +49,7 @@ describe('Fastify adapter tests - rpc handler', () => {
4949
expect.objectContaining({ title: 'post1' }),
5050
expect.objectContaining({ title: 'post2' }),
5151
]),
52-
})
52+
}),
5353
);
5454

5555
r = await app.inject({
@@ -97,7 +97,7 @@ describe('Fastify adapter tests - rpc handler', () => {
9797
expect.arrayContaining([
9898
expect.objectContaining({ published: true, _sum: { viewCount: 1 } }),
9999
expect.objectContaining({ published: false, _sum: { viewCount: 2 } }),
100-
])
100+
]),
101101
);
102102

103103
r = await app.inject({

packages/server/test/adapter/hono.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ describe('Hono adapter tests - rpc handler', () => {
1010
it('properly handles requests', async () => {
1111
const client = await createTestClient(schema);
1212

13-
const handler = await createHonoApp(createHonoHandler({ getClient: () => client, apiHandler: new RPCApiHandler({schema: client.$schema}) }));
13+
const handler = await createHonoApp(
14+
createHonoHandler({ getClient: () => client, apiHandler: new RPCApiHandler({ schema: client.$schema }) }),
15+
);
1416

1517
let r = await handler(makeRequest('GET', makeUrl('/api/post/findMany', { where: { id: { equals: '1' } } })));
1618
expect(r.status).toBe(200);
@@ -29,7 +31,7 @@ describe('Hono adapter tests - rpc handler', () => {
2931
],
3032
},
3133
},
32-
})
34+
}),
3335
);
3436
expect(r.status).toBe(201);
3537
expect((await unmarshal(r)).data).toMatchObject({
@@ -49,7 +51,7 @@ describe('Hono adapter tests - rpc handler', () => {
4951
expect((await unmarshal(r)).data).toHaveLength(1);
5052

5153
r = await handler(
52-
makeRequest('PUT', '/api/user/update', { where: { id: 'user1' }, data: { email: '[email protected]' } })
54+
makeRequest('PUT', '/api/user/update', { where: { id: 'user1' }, data: { email: '[email protected]' } }),
5355
);
5456
expect(r.status).toBe(200);
5557
expect((await unmarshal(r)).data.email).toBe('[email protected]');
@@ -63,14 +65,14 @@ describe('Hono adapter tests - rpc handler', () => {
6365
expect((await unmarshal(r)).data._sum.viewCount).toBe(3);
6466

6567
r = await handler(
66-
makeRequest('GET', makeUrl('/api/post/groupBy', { by: ['published'], _sum: { viewCount: true } }))
68+
makeRequest('GET', makeUrl('/api/post/groupBy', { by: ['published'], _sum: { viewCount: true } })),
6769
);
6870
expect(r.status).toBe(200);
6971
expect((await unmarshal(r)).data).toEqual(
7072
expect.arrayContaining([
7173
expect.objectContaining({ published: true, _sum: { viewCount: 1 } }),
7274
expect.objectContaining({ published: false, _sum: { viewCount: 2 } }),
73-
])
75+
]),
7476
);
7577

7678
r = await handler(makeRequest('DELETE', makeUrl('/api/user/deleteMany', { where: { id: 'user1' } })));
@@ -87,7 +89,7 @@ describe('Hono adapter tests - rest handler', () => {
8789
createHonoHandler({
8890
getClient: () => client,
8991
apiHandler: new RestApiHandler({ endpoint: 'http://localhost/api', schema: client.$schema }),
90-
})
92+
}),
9193
);
9294

9395
let r = await handler(makeRequest('GET', makeUrl('/api/post/1')));
@@ -99,7 +101,7 @@ describe('Hono adapter tests - rest handler', () => {
99101
type: 'user',
100102
attributes: { id: 'user1', email: '[email protected]' },
101103
},
102-
})
104+
}),
103105
);
104106
expect(r.status).toBe(201);
105107
expect(await unmarshal(r)).toMatchObject({
@@ -126,7 +128,7 @@ describe('Hono adapter tests - rest handler', () => {
126128
r = await handler(
127129
makeRequest('PUT', makeUrl('/api/user/user1'), {
128130
data: { type: 'user', attributes: { email: '[email protected]' } },
129-
})
131+
}),
130132
);
131133
expect(r.status).toBe(200);
132134
expect((await unmarshal(r)).data.attributes.email).toBe('[email protected]');

0 commit comments

Comments
 (0)