mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
fix(db): isolate AstroDbError from core utils (#10646)
* fix(db): isolate AstroDbError from core utils * add changeset
This commit is contained in:
parent
51112ab3f1
commit
713f99e849
6 changed files with 14 additions and 10 deletions
5
.changeset/dull-news-grab.md
Normal file
5
.changeset/dull-news-grab.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/db": patch
|
||||
---
|
||||
|
||||
Fixes an issue astro:db could not be used on serverless platforms.
|
|
@ -7,7 +7,7 @@ import { blue, yellow } from 'kleur/colors';
|
|||
import { loadEnv } from 'vite';
|
||||
import parseArgs from 'yargs-parser';
|
||||
import { SEED_DEV_FILE_NAME } from '../../runtime/queries.js';
|
||||
import { AstroDbError } from '../../utils.js';
|
||||
import { AstroDbError } from '../../runtime/utils.js';
|
||||
import { CONFIG_FILE_NAMES, DB_PATH } from '../consts.js';
|
||||
import { resolveDbConfig } from '../load-file.js';
|
||||
import { type ManagedAppToken, getManagedAppTokenOrExit } from '../tokens.js';
|
||||
|
|
|
@ -4,8 +4,7 @@ import type { LibSQLDatabase } from 'drizzle-orm/libsql';
|
|||
import { drizzle as drizzleLibsql } from 'drizzle-orm/libsql';
|
||||
import { type SqliteRemoteDatabase, drizzle as drizzleProxy } from 'drizzle-orm/sqlite-proxy';
|
||||
import { z } from 'zod';
|
||||
import { AstroDbError } from '../utils.js';
|
||||
import { safeFetch } from './utils.js';
|
||||
import { AstroDbError, safeFetch } from './utils.js';
|
||||
|
||||
const isWebContainer = !!process.versions?.webcontainer;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { type SQL, sql } from 'drizzle-orm';
|
|||
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
|
||||
import { SQLiteAsyncDialect } from 'drizzle-orm/sqlite-core';
|
||||
import { type DBTables } from '../core/types.js';
|
||||
import { AstroDbError } from '../utils.js';
|
||||
import { AstroDbError } from './utils.js';
|
||||
import { SEED_DEFAULT_EXPORT_ERROR } from './errors.js';
|
||||
import { getCreateIndexQueries, getCreateTableQuery } from './queries.js';
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { AstroError } from 'astro/errors';
|
||||
|
||||
/**
|
||||
* Small wrapper around fetch that throws an error if the response is not OK. Allows for custom error handling as well through the onNotOK callback.
|
||||
*/
|
||||
|
@ -16,3 +18,7 @@ export async function safeFetch(
|
|||
|
||||
return response;
|
||||
}
|
||||
|
||||
export class AstroDbError extends AstroError {
|
||||
name = 'Astro DB Error';
|
||||
}
|
||||
|
|
|
@ -1,8 +1,2 @@
|
|||
import { AstroError } from 'astro/errors';
|
||||
|
||||
export { defineDbIntegration } from './core/utils.js';
|
||||
export { asDrizzleTable } from './runtime/index.js';
|
||||
|
||||
export class AstroDbError extends AstroError {
|
||||
name = 'Astro DB Error';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue