Skip to content

Commit 35f8655

Browse files
committed
Clean up & format
1 parent d857512 commit 35f8655

19 files changed

Lines changed: 92 additions & 99 deletions

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"bytea",
55
"croner",
66
"healthcheck",
7+
"introspector",
78
"kysely",
89
"openworkers",
910
"postgate",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ api.get('/cron-test', (c) => {
5858
pattern: cron.pattern(),
5959
description: cron.describe(),
6060
nextRun: cron.nextRun()?.toISOString() ?? null,
61-
nextRuns: cron.nextRuns(5).map((d: Date) => d.toISOString()),
61+
nextRuns: cron.nextRuns(5).map((d: Date) => d.toISOString())
6262
});
6363
} catch (error) {
6464
return c.json({ status: 'error', wasm: true, error: String(error) }, 400);

src/routes/workers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,9 @@ workers.post('/:id/upload', async (c) => {
318318

319319
// 3b. Parse asset manifest from form data (sent separately from zip)
320320
const assetsManifest = formData.get('assets');
321-
const assetEntries: Array<{ path: string; size: number; contentType: string; hash: string }> =
322-
assetsManifest ? JSON.parse(assetsManifest as string) : [];
321+
const assetEntries: Array<{ path: string; size: number; contentType: string; hash: string }> = assetsManifest
322+
? JSON.parse(assetsManifest as string)
323+
: [];
323324

324325
// 4. Extract zip (code-only: worker script, routes, functions)
325326
const zipBuffer = await file.arrayBuffer();

src/services/db/crons.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ export async function findCronById(userId: string, cronId: string): Promise<ICro
88
const cron = await kysely
99
.selectFrom('crons')
1010
.innerJoin('workers', 'crons.workerId', 'workers.id')
11-
.select(['crons.id', 'crons.value', 'crons.workerId', 'crons.nextRun', 'crons.lastRun', 'crons.createdAt', 'crons.updatedAt'])
11+
.select([
12+
'crons.id',
13+
'crons.value',
14+
'crons.workerId',
15+
'crons.nextRun',
16+
'crons.lastRun',
17+
'crons.createdAt',
18+
'crons.updatedAt'
19+
])
1220
.where('crons.id', '=', uuid(cronId))
1321
.where('workers.userId', '=', uuid(userId))
1422
.executeTakeFirst();
@@ -28,7 +36,7 @@ export async function createCron(userId: string, workerId: string, value: string
2836
.values({
2937
value,
3038
workerId: uuid(workerId),
31-
nextRun: timestamptz(nextRun),
39+
nextRun: timestamptz(nextRun)
3240
})
3341
.returningAll()
3442
.executeTakeFirstOrThrow();

src/services/db/database-tokens.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ export async function createDatabaseToken(
5050
name,
5151
tokenHash,
5252
tokenPrefix,
53-
allowedOperations: textArray(allowedOperations),
53+
allowedOperations: textArray(allowedOperations)
5454
})
5555
.returning(['id', 'databaseId', 'name', 'tokenPrefix', 'allowedOperations', 'lastUsedAt', 'createdAt'])
5656
.executeTakeFirstOrThrow();
5757

5858
return {
5959
token,
60-
fullToken,
60+
fullToken
6161
};
6262
}
6363

@@ -123,7 +123,7 @@ async function createSystemToken(databaseId: string): Promise<string> {
123123
name: SYSTEM_TOKEN_NAME,
124124
tokenHash,
125125
tokenPrefix,
126-
allowedOperations: textArray(ALL_OPERATIONS),
126+
allowedOperations: textArray(ALL_OPERATIONS)
127127
})
128128
.onConflict((oc) => oc.columns(['databaseId', 'name']).doNothing())
129129
.execute();

src/services/db/databases.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function createPlatformDatabase(userId: string, input: CreatePlatfo
6565
provider: enumCast('platform' as DatabaseProvider, 'database_provider'),
6666
schemaName: input.schemaName,
6767
maxRows: input.maxRows,
68-
timeoutSeconds: input.timeoutSeconds,
68+
timeoutSeconds: input.timeoutSeconds
6969
})
7070
.returningAll()
7171
.executeTakeFirstOrThrow();
@@ -89,7 +89,7 @@ export async function createPostgresDatabase(userId: string, input: CreatePostgr
8989
provider: enumCast('postgres' as DatabaseProvider, 'database_provider'),
9090
connectionString: input.connectionString,
9191
maxRows: input.maxRows,
92-
timeoutSeconds: input.timeoutSeconds,
92+
timeoutSeconds: input.timeoutSeconds
9393
})
9494
.returningAll()
9595
.executeTakeFirstOrThrow();

src/services/db/domains.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ export async function findAllDomains(userId: string): Promise<IDomain[]> {
1313
}
1414

1515
export async function findDomainByName(name: string): Promise<IDomain | null> {
16-
const domain = await kysely
17-
.selectFrom('domains')
18-
.selectAll()
19-
.where('name', '=', name)
20-
.executeTakeFirst();
16+
const domain = await kysely.selectFrom('domains').selectAll().where('name', '=', name).executeTakeFirst();
2117

2218
return domain ?? null;
2319
}
@@ -34,7 +30,7 @@ export async function createDomain(userId: string, workerId: string, name: strin
3430
.values({
3531
name,
3632
workerId: uuid(workerId),
37-
userId: uuid(userId),
33+
userId: uuid(userId)
3834
})
3935
.returningAll()
4036
.executeTakeFirstOrThrow();
@@ -92,6 +88,6 @@ export async function updateWorkerDomains(userId: string, workerId: string, newD
9288
toDelete.length > 0 ? deleteDomainsForWorker(userId, workerId, toDelete) : Promise.resolve(0),
9389

9490
// Create new domains
95-
...toCreate.map((name) => createDomain(userId, workerId, name)),
91+
...toCreate.map((name) => createDomain(userId, workerId, name))
9692
]);
9793
}

src/services/db/environments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export async function createEnvironment(userId: string, name: string, desc?: str
140140
.values({
141141
name,
142142
desc: desc ?? null,
143-
userId: uuid(userId),
143+
userId: uuid(userId)
144144
})
145145
.returning(['id', 'name', 'desc', 'userId', 'createdAt', 'updatedAt'])
146146
.executeTakeFirstOrThrow();
@@ -149,7 +149,7 @@ export async function createEnvironment(userId: string, name: string, desc?: str
149149
return {
150150
...env,
151151
values: [],
152-
workers: [],
152+
workers: []
153153
};
154154
}
155155

@@ -184,7 +184,7 @@ export async function updateEnvironment(
184184
return {
185185
...env,
186186
values: current.values,
187-
workers: current.workers,
187+
workers: current.workers
188188
};
189189
}
190190

@@ -214,7 +214,7 @@ export async function createEnvironmentValue(
214214
value,
215215
type: enumCast(type as 'var' | 'secret', 'enum_binding_type'),
216216
environmentId: uuid(envId),
217-
userId: uuid(userId),
217+
userId: uuid(userId)
218218
})
219219
.returningAll()
220220
.executeTakeFirstOrThrow();

src/services/db/kv.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('KV service - Kysely SQL generation', () => {
2828
.values({
2929
userId: sql<string>`${userId}::uuid`,
3030
name,
31-
desc,
31+
desc
3232
})
3333
.returningAll()
3434
.compile();
@@ -47,7 +47,7 @@ describe('KV service - Kysely SQL generation', () => {
4747
.updateTable('kvConfigs')
4848
.set({
4949
name,
50-
updatedAt: sql`now()`,
50+
updatedAt: sql`now()`
5151
})
5252
.where('userId', '=', sql<string>`${userId}::uuid`)
5353
.where('id', '=', sql<string>`${id}::uuid`)
@@ -106,13 +106,13 @@ describe('KV service - Kysely SQL generation', () => {
106106
namespaceId: sql<string>`${namespaceId}::uuid`,
107107
key,
108108
value: sql`${jsonValue}::jsonb`,
109-
expiresAt: sql`${expiresAt}::timestamptz`,
109+
expiresAt: sql`${expiresAt}::timestamptz`
110110
})
111111
.onConflict((oc) =>
112112
oc.columns(['namespaceId', 'key']).doUpdateSet({
113113
value: sql`${jsonValue}::jsonb`,
114114
expiresAt: sql`${expiresAt}::timestamptz`,
115-
updatedAt: sql`now()`,
115+
updatedAt: sql`now()`
116116
})
117117
)
118118
.returningAll()

src/services/db/kysely-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export interface Database {
119119
id: Generated<string>;
120120
key: string;
121121
value: string;
122-
type: 'var' | 'secret';
122+
type: 'var' | 'secret' | 'assets' | 'storage' | 'kv' | 'database' | 'worker';
123123
environmentId: string;
124124
userId: string;
125125
createdAt: Generated<Date>;

0 commit comments

Comments
 (0)