added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions

View File

@@ -12,7 +12,7 @@ export type D1ConnectionConfig = {
class CustomD1Dialect extends D1Dialect {
override createIntrospector(db: Kysely<any>): DatabaseIntrospector {
return new SqliteIntrospector(db, {
excludeTables: ["_cf_KV"]
excludeTables: ["_cf_KV"],
});
}
}
@@ -23,7 +23,7 @@ export class D1Connection extends SqliteConnection {
const kysely = new Kysely({
dialect: new CustomD1Dialect({ database: config.binding }),
plugins
plugins,
});
super(kysely, {}, plugins);
}
@@ -37,7 +37,7 @@ export class D1Connection extends SqliteConnection {
}
protected override async batch<Queries extends QB[]>(
queries: [...Queries]
queries: [...Queries],
): Promise<{
[K in keyof Queries]: Awaited<ReturnType<Queries[K]["execute"]>>;
}> {
@@ -47,7 +47,7 @@ export class D1Connection extends SqliteConnection {
queries.map((q) => {
const { sql, parameters } = q.compile();
return db.prepare(sql).bind(...parameters);
})
}),
);
// let it run through plugins

View File

@@ -8,9 +8,9 @@ import { getBindings } from "./bindings";
export function makeSchema(bindings: string[] = []) {
return Type.Object(
{
binding: bindings.length > 0 ? StringEnum(bindings) : Type.Optional(Type.String())
binding: bindings.length > 0 ? StringEnum(bindings) : Type.Optional(Type.String()),
},
{ title: "R2", description: "Cloudflare R2 storage" }
{ title: "R2", description: "Cloudflare R2 storage" },
);
}
@@ -36,10 +36,10 @@ export function registerMedia(env: Record<string, any>) {
override toJSON() {
return {
...super.toJSON(),
config: this.config
config: this.config,
};
}
}
},
);
}
@@ -67,13 +67,13 @@ export class StorageR2Adapter implements StorageAdapter {
}
}
async listObjects(
prefix?: string
prefix?: string,
): Promise<{ key: string; last_modified: Date; size: number }[]> {
const list = await this.bucket.list({ limit: 50 });
return list.objects.map((item) => ({
key: item.key,
size: item.size,
last_modified: item.uploaded
last_modified: item.uploaded,
}));
}
@@ -89,7 +89,7 @@ export class StorageR2Adapter implements StorageAdapter {
let object: R2ObjectBody | null;
const responseHeaders = new Headers({
"Accept-Ranges": "bytes",
"Content-Type": guess(key)
"Content-Type": guess(key),
});
//console.log("getObject:headers", headersToObject(headers));
@@ -98,7 +98,7 @@ export class StorageR2Adapter implements StorageAdapter {
? {} // miniflare doesn't support range requests
: {
range: headers,
onlyIf: headers
onlyIf: headers,
};
object = (await this.bucket.get(key, options)) as R2ObjectBody;
@@ -130,7 +130,7 @@ export class StorageR2Adapter implements StorageAdapter {
return new Response(object.body, {
status: object.range ? 206 : 200,
headers: responseHeaders
headers: responseHeaders,
});
}
@@ -139,7 +139,7 @@ export class StorageR2Adapter implements StorageAdapter {
if (!metadata || Object.keys(metadata).length === 0) {
// guessing is especially required for dev environment (miniflare)
metadata = {
contentType: guess(object.key)
contentType: guess(object.key),
};
}
@@ -157,7 +157,7 @@ export class StorageR2Adapter implements StorageAdapter {
return {
type: String(head.httpMetadata?.contentType ?? guess(key)),
size: head.size
size: head.size,
};
}
@@ -172,7 +172,7 @@ export class StorageR2Adapter implements StorageAdapter {
toJSON(secrets?: boolean) {
return {
type: this.getName(),
config: {}
config: {},
};
}
}

View File

@@ -15,7 +15,7 @@ export function getBindings<T extends GetBindingType>(env: any, type: T): Bindin
if (env[key] && (env[key] as any).constructor.name === type) {
bindings.push({
key,
value: env[key] as BindingTypeMap[T]
value: env[key] as BindingTypeMap[T],
});
}
} catch (e) {}

View File

@@ -84,7 +84,7 @@ export function serve<Env = any>(config: CloudflareBkndConfig<Env> = {}) {
hono.all("*", async (c, next) => {
const res = await serveStatic({
path: `./${pathname}`,
manifest: config.manifest!
manifest: config.manifest!,
})(c as any, next);
if (res instanceof Response) {
const ttl = 60 * 60 * 24 * 365;
@@ -114,6 +114,6 @@ export function serve<Env = any>(config: CloudflareBkndConfig<Env> = {}) {
default:
throw new Error(`Unknown mode ${mode}`);
}
}
},
};
}

View File

@@ -10,7 +10,7 @@ export {
getBindings,
type BindingTypeMap,
type GetBindingType,
type BindingMap
type BindingMap,
} from "./bindings";
export function d1(config: D1ConnectionConfig) {

View File

@@ -31,13 +31,13 @@ export async function getCached(config: CloudflareBkndConfig, { env, ctx, ...arg
async ({ params: { app } }) => {
saveConfig(app.toJSON(true));
},
"sync"
"sync",
);
await config.beforeBuild?.(app);
},
adminOptions: { html: config.html }
adminOptions: { html: config.html },
},
{ env, ctx, ...args }
{ env, ctx, ...args },
);
if (!cachedConfig) {

View File

@@ -23,7 +23,7 @@ export async function getDurable(config: CloudflareBkndConfig, ctx: Context) {
config: create_config,
html: config.html,
keepAliveSeconds: config.keepAliveSeconds,
setAdminHtml: config.setAdminHtml
setAdminHtml: config.setAdminHtml,
});
const headers = new Headers(res.headers);
@@ -32,7 +32,7 @@ export async function getDurable(config: CloudflareBkndConfig, ctx: Context) {
return new Response(res.body, {
status: res.status,
statusText: res.statusText,
headers
headers,
});
}
@@ -48,7 +48,7 @@ export class DurableBkndApp extends DurableObject {
html?: string;
keepAliveSeconds?: number;
setAdminHtml?: boolean;
}
},
) {
let buildtime = 0;
if (!this.app) {
@@ -73,7 +73,7 @@ export class DurableBkndApp extends DurableObject {
return c.json({
id: this.id,
keepAliveSeconds: options?.keepAliveSeconds ?? 0,
colo: context.colo
colo: context.colo,
});
});
@@ -82,7 +82,7 @@ export class DurableBkndApp extends DurableObject {
adminOptions: { html: options.html },
beforeBuild: async (app) => {
await this.beforeBuild(app);
}
},
});
buildtime = performance.now() - start;
@@ -101,7 +101,7 @@ export class DurableBkndApp extends DurableObject {
return new Response(res.body, {
status: res.status,
statusText: res.statusText,
headers
headers,
});
}

View File

@@ -6,9 +6,9 @@ export async function makeApp(config: CloudflareBkndConfig, ctx: Context) {
return await createRuntimeApp(
{
...makeCfConfig(config, ctx),
adminOptions: config.html ? { html: config.html } : undefined
adminOptions: config.html ? { html: config.html } : undefined,
},
ctx
ctx,
);
}