mirror of
https://github.com/andwati/andwati.com.git
synced 2026-10-18 09:22:53 +00:00
Fixes the formatting deltas from the initial Astro/Strapi scaffold and brings the legacy generate-og-images/generate-llms/validate-post scripts in line with Biome's style. No behavioral changes.
95 lines
2.8 KiB
TypeScript
95 lines
2.8 KiB
TypeScript
import { isDatabaseClientKind } from "@strapi/database";
|
|
import type { Core } from "@strapi/strapi";
|
|
import path from "path";
|
|
|
|
const config = ({
|
|
env,
|
|
}: Core.Config.Shared.ConfigParams): Core.Config.Database => {
|
|
const client = env("DATABASE_CLIENT", "sqlite");
|
|
|
|
if (!isDatabaseClientKind(client)) {
|
|
throw new Error(
|
|
`Unsupported DATABASE_CLIENT: ${client}. Use "postgres", "mysql", or "sqlite".`,
|
|
);
|
|
}
|
|
|
|
const connections: Record<
|
|
Core.Config.Database.ClientKind,
|
|
Core.Config.Database["connection"]
|
|
> = {
|
|
mysql: {
|
|
client: "mysql",
|
|
connection: {
|
|
host: env("DATABASE_HOST", "localhost"),
|
|
port: env.int("DATABASE_PORT", 3306),
|
|
database: env("DATABASE_NAME", "strapi"),
|
|
user: env("DATABASE_USERNAME", "strapi"),
|
|
password: env("DATABASE_PASSWORD", "strapi"),
|
|
ssl: env.bool("DATABASE_SSL", false) && {
|
|
key: env("DATABASE_SSL_KEY", undefined),
|
|
cert: env("DATABASE_SSL_CERT", undefined),
|
|
ca: env("DATABASE_SSL_CA", undefined),
|
|
capath: env("DATABASE_SSL_CAPATH", undefined),
|
|
cipher: env("DATABASE_SSL_CIPHER", undefined),
|
|
rejectUnauthorized: env.bool(
|
|
"DATABASE_SSL_REJECT_UNAUTHORIZED",
|
|
true,
|
|
),
|
|
},
|
|
},
|
|
pool: {
|
|
min: env.int("DATABASE_POOL_MIN", 2),
|
|
max: env.int("DATABASE_POOL_MAX", 10),
|
|
},
|
|
},
|
|
postgres: {
|
|
client: "postgres",
|
|
connection: {
|
|
connectionString: env("DATABASE_URL"),
|
|
host: env("DATABASE_HOST", "localhost"),
|
|
port: env.int("DATABASE_PORT", 5432),
|
|
database: env("DATABASE_NAME", "strapi"),
|
|
user: env("DATABASE_USERNAME", "strapi"),
|
|
password: env("DATABASE_PASSWORD", "strapi"),
|
|
ssl: env.bool("DATABASE_SSL", false) && {
|
|
key: env("DATABASE_SSL_KEY", undefined),
|
|
cert: env("DATABASE_SSL_CERT", undefined),
|
|
ca: env("DATABASE_SSL_CA", undefined),
|
|
capath: env("DATABASE_SSL_CAPATH", undefined),
|
|
cipher: env("DATABASE_SSL_CIPHER", undefined),
|
|
rejectUnauthorized: env.bool(
|
|
"DATABASE_SSL_REJECT_UNAUTHORIZED",
|
|
true,
|
|
),
|
|
},
|
|
schema: env("DATABASE_SCHEMA", "public"),
|
|
},
|
|
pool: {
|
|
min: env.int("DATABASE_POOL_MIN", 2),
|
|
max: env.int("DATABASE_POOL_MAX", 10),
|
|
},
|
|
},
|
|
sqlite: {
|
|
client: "sqlite",
|
|
connection: {
|
|
filename: path.join(
|
|
__dirname,
|
|
"..",
|
|
"..",
|
|
env("DATABASE_FILENAME", ".tmp/data.db"),
|
|
),
|
|
},
|
|
useNullAsDefault: true,
|
|
},
|
|
};
|
|
|
|
return {
|
|
connection: {
|
|
...connections[client],
|
|
acquireConnectionTimeout: env.int("DATABASE_CONNECTION_TIMEOUT", 60000),
|
|
},
|
|
};
|
|
};
|
|
|
|
export default config;
|