create-prisma 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -16
- package/dist/cli.mjs +1 -1
- package/dist/{create-Dz9GFGFQ.mjs → create-DgN5mAMV.mjs} +1031 -444
- package/dist/index.d.mts +31 -57
- package/dist/index.mjs +10 -21
- package/package.json +2 -2
- package/templates/create/astro/.yarnrc.yml.hbs +3 -0
- package/templates/create/astro/README.md.hbs +35 -0
- package/templates/create/astro/astro.config.mjs +5 -0
- package/templates/create/astro/deno.json.hbs +5 -0
- package/templates/create/astro/package.json.hbs +22 -0
- package/templates/{init → create/astro}/prisma/schema.prisma.hbs +4 -1
- package/templates/create/astro/prisma/seed.ts.hbs +38 -0
- package/templates/{init/prisma.config.ts.hbs → create/astro/prisma.config.ts} +1 -0
- package/templates/create/astro/public/favicon.svg +14 -0
- package/templates/create/astro/src/env.d.ts +9 -0
- package/templates/create/astro/src/lib/prisma.ts.hbs +53 -0
- package/templates/create/astro/src/pages/api/users.ts.hbs +42 -0
- package/templates/create/astro/src/pages/index.astro.hbs +236 -0
- package/templates/create/astro/tsconfig.json +5 -0
- package/templates/create/hono/.yarnrc.yml.hbs +3 -0
- package/templates/create/hono/README.md.hbs +13 -48
- package/templates/create/hono/deno.json.hbs +5 -0
- package/templates/create/hono/package.json.hbs +3 -0
- package/templates/create/hono/prisma/schema.prisma.hbs +21 -0
- package/templates/create/hono/prisma/seed.ts.hbs +38 -0
- package/templates/create/hono/prisma.config.ts +13 -0
- package/templates/create/hono/src/index.ts.hbs +1 -1
- package/templates/{init/prisma/index.ts.hbs → create/hono/src/lib/prisma.ts.hbs} +14 -13
- package/templates/create/hono/tsconfig.json +1 -2
- package/templates/create/next/.yarnrc.yml.hbs +3 -0
- package/templates/create/next/README.md.hbs +8 -23
- package/templates/create/next/deno.json.hbs +12 -0
- package/templates/create/next/package.json.hbs +4 -0
- package/templates/create/next/prisma/schema.prisma.hbs +21 -0
- package/templates/create/next/prisma/seed.ts.hbs +38 -0
- package/templates/create/next/prisma.config.ts +13 -0
- package/templates/create/next/src/app/globals.css +136 -0
- package/templates/create/next/src/app/page.tsx.hbs +104 -0
- package/templates/create/next/src/lib/prisma.ts.hbs +53 -0
- package/templates/create/nuxt/.yarnrc.yml.hbs +3 -0
- package/templates/create/nuxt/README.md.hbs +32 -0
- package/templates/create/nuxt/app/app.vue +4 -0
- package/templates/create/nuxt/app/pages/index.vue.hbs +230 -0
- package/templates/create/nuxt/deno.json.hbs +5 -0
- package/templates/create/nuxt/nuxt.config.ts +5 -0
- package/templates/create/nuxt/package.json.hbs +27 -0
- package/templates/create/nuxt/prisma/schema.prisma.hbs +21 -0
- package/templates/create/nuxt/prisma/seed.ts.hbs +38 -0
- package/templates/create/nuxt/prisma.config.ts +13 -0
- package/templates/create/nuxt/public/robots.txt +2 -0
- package/templates/create/nuxt/server/api/users.get.ts.hbs +36 -0
- package/templates/create/nuxt/server/utils/prisma.ts.hbs +53 -0
- package/templates/create/nuxt/tsconfig.json +17 -0
- package/templates/create/svelte/.vscode/extensions.json +3 -0
- package/templates/create/svelte/.yarnrc.yml.hbs +3 -0
- package/templates/create/svelte/README.md.hbs +34 -0
- package/templates/create/svelte/deno.json.hbs +5 -0
- package/templates/create/svelte/package.json.hbs +28 -0
- package/templates/create/svelte/prisma/schema.prisma.hbs +21 -0
- package/templates/create/svelte/prisma/seed.ts.hbs +87 -0
- package/templates/create/svelte/prisma.config.ts +13 -0
- package/templates/create/svelte/src/app.d.ts +13 -0
- package/templates/create/svelte/src/app.html +11 -0
- package/templates/create/svelte/src/lib/assets/favicon.svg +1 -0
- package/templates/create/svelte/src/lib/index.ts +1 -0
- package/templates/create/svelte/src/lib/server/prisma.ts.hbs +53 -0
- package/templates/create/svelte/src/routes/+layout.svelte +11 -0
- package/templates/create/svelte/src/routes/+page.server.ts.hbs +28 -0
- package/templates/create/svelte/src/routes/+page.svelte.hbs +350 -0
- package/templates/create/svelte/static/robots.txt +3 -0
- package/templates/create/svelte/svelte.config.js +13 -0
- package/templates/create/svelte/tsconfig.json +20 -0
- package/templates/create/svelte/vite.config.ts +6 -0
- package/templates/create/turborepo/.yarnrc.yml.hbs +3 -0
- package/templates/create/turborepo/README.md.hbs +29 -0
- package/templates/create/turborepo/apps/api/package.json.hbs +21 -0
- package/templates/create/turborepo/apps/api/src/index.ts.hbs +45 -0
- package/templates/create/turborepo/apps/api/tsconfig.json +17 -0
- package/templates/create/turborepo/deno.json.hbs +5 -0
- package/templates/create/turborepo/package.json.hbs +24 -0
- package/templates/create/turborepo/packages/db/package.json.hbs +17 -0
- package/templates/create/turborepo/packages/db/prisma/schema.prisma.hbs +21 -0
- package/templates/create/turborepo/packages/db/prisma/seed.ts.hbs +38 -0
- package/templates/create/turborepo/packages/db/prisma.config.ts +13 -0
- package/templates/create/turborepo/packages/db/src/client.ts.hbs +58 -0
- package/templates/create/turborepo/packages/db/src/index.ts +2 -0
- package/templates/create/turborepo/packages/db/tsconfig.json +19 -0
- package/templates/create/turborepo/turbo.json +34 -0
- package/templates/create/next/app/globals.css +0 -47
- package/templates/create/next/app/page.tsx.hbs +0 -46
- /package/templates/create/next/{app → src/app}/layout.tsx.hbs +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -187,7 +187,9 @@ declare const DatabaseProviderSchema: z.ZodEnum<{
|
|
|
187
187
|
declare const PackageManagerSchema: z.ZodEnum<{
|
|
188
188
|
npm: "npm";
|
|
189
189
|
pnpm: "pnpm";
|
|
190
|
+
yarn: "yarn";
|
|
190
191
|
bun: "bun";
|
|
192
|
+
deno: "deno";
|
|
191
193
|
}>;
|
|
192
194
|
declare const SchemaPresetSchema: z.ZodEnum<{
|
|
193
195
|
empty: "empty";
|
|
@@ -196,9 +198,13 @@ declare const SchemaPresetSchema: z.ZodEnum<{
|
|
|
196
198
|
declare const CreateTemplateSchema: z.ZodEnum<{
|
|
197
199
|
hono: "hono";
|
|
198
200
|
next: "next";
|
|
201
|
+
svelte: "svelte";
|
|
202
|
+
astro: "astro";
|
|
203
|
+
nuxt: "nuxt";
|
|
204
|
+
turborepo: "turborepo";
|
|
199
205
|
}>;
|
|
200
206
|
declare const DatabaseUrlSchema: z.ZodString;
|
|
201
|
-
declare const
|
|
207
|
+
declare const CreateCommandInputSchema: z.ZodObject<{
|
|
202
208
|
yes: z.ZodOptional<z.ZodBoolean>;
|
|
203
209
|
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
204
210
|
provider: z.ZodOptional<z.ZodEnum<{
|
|
@@ -211,7 +217,9 @@ declare const InitCommandInputSchema: z.ZodObject<{
|
|
|
211
217
|
packageManager: z.ZodOptional<z.ZodEnum<{
|
|
212
218
|
npm: "npm";
|
|
213
219
|
pnpm: "pnpm";
|
|
220
|
+
yarn: "yarn";
|
|
214
221
|
bun: "bun";
|
|
222
|
+
deno: "deno";
|
|
215
223
|
}>>;
|
|
216
224
|
prismaPostgres: z.ZodOptional<z.ZodBoolean>;
|
|
217
225
|
databaseUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -221,37 +229,19 @@ declare const InitCommandInputSchema: z.ZodObject<{
|
|
|
221
229
|
empty: "empty";
|
|
222
230
|
basic: "basic";
|
|
223
231
|
}>>;
|
|
224
|
-
}, z.core.$strip>;
|
|
225
|
-
type InitCommandInput = z.infer<typeof InitCommandInputSchema>;
|
|
226
|
-
declare const CreateCommandInputSchema: z.ZodObject<{
|
|
227
|
-
yes: z.ZodOptional<z.ZodBoolean>;
|
|
228
|
-
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
229
232
|
name: z.ZodOptional<z.ZodString>;
|
|
230
233
|
template: z.ZodOptional<z.ZodEnum<{
|
|
231
234
|
hono: "hono";
|
|
232
235
|
next: "next";
|
|
236
|
+
svelte: "svelte";
|
|
237
|
+
astro: "astro";
|
|
238
|
+
nuxt: "nuxt";
|
|
239
|
+
turborepo: "turborepo";
|
|
233
240
|
}>>;
|
|
241
|
+
skills: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
mcp: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
extension: z.ZodOptional<z.ZodBoolean>;
|
|
234
244
|
force: z.ZodOptional<z.ZodBoolean>;
|
|
235
|
-
provider: z.ZodOptional<z.ZodEnum<{
|
|
236
|
-
postgresql: "postgresql";
|
|
237
|
-
mysql: "mysql";
|
|
238
|
-
sqlite: "sqlite";
|
|
239
|
-
sqlserver: "sqlserver";
|
|
240
|
-
cockroachdb: "cockroachdb";
|
|
241
|
-
}>>;
|
|
242
|
-
packageManager: z.ZodOptional<z.ZodEnum<{
|
|
243
|
-
npm: "npm";
|
|
244
|
-
pnpm: "pnpm";
|
|
245
|
-
bun: "bun";
|
|
246
|
-
}>>;
|
|
247
|
-
prismaPostgres: z.ZodOptional<z.ZodBoolean>;
|
|
248
|
-
databaseUrl: z.ZodOptional<z.ZodString>;
|
|
249
|
-
install: z.ZodOptional<z.ZodBoolean>;
|
|
250
|
-
generate: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
-
schemaPreset: z.ZodOptional<z.ZodEnum<{
|
|
252
|
-
empty: "empty";
|
|
253
|
-
basic: "basic";
|
|
254
|
-
}>>;
|
|
255
245
|
}, z.core.$strip>;
|
|
256
246
|
type CreateCommandInput = z.infer<typeof CreateCommandInputSchema>;
|
|
257
247
|
//#endregion
|
|
@@ -260,12 +250,6 @@ declare const router: {
|
|
|
260
250
|
create: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, zod.ZodOptional<zod.ZodObject<{
|
|
261
251
|
yes: zod.ZodOptional<zod.ZodBoolean>;
|
|
262
252
|
verbose: zod.ZodOptional<zod.ZodBoolean>;
|
|
263
|
-
name: zod.ZodOptional<zod.ZodString>;
|
|
264
|
-
template: zod.ZodOptional<zod.ZodEnum<{
|
|
265
|
-
hono: "hono";
|
|
266
|
-
next: "next";
|
|
267
|
-
}>>;
|
|
268
|
-
force: zod.ZodOptional<zod.ZodBoolean>;
|
|
269
253
|
provider: zod.ZodOptional<zod.ZodEnum<{
|
|
270
254
|
postgresql: "postgresql";
|
|
271
255
|
mysql: "mysql";
|
|
@@ -276,7 +260,9 @@ declare const router: {
|
|
|
276
260
|
packageManager: zod.ZodOptional<zod.ZodEnum<{
|
|
277
261
|
npm: "npm";
|
|
278
262
|
pnpm: "pnpm";
|
|
263
|
+
yarn: "yarn";
|
|
279
264
|
bun: "bun";
|
|
265
|
+
deno: "deno";
|
|
280
266
|
}>>;
|
|
281
267
|
prismaPostgres: zod.ZodOptional<zod.ZodBoolean>;
|
|
282
268
|
databaseUrl: zod.ZodOptional<zod.ZodString>;
|
|
@@ -286,34 +272,22 @@ declare const router: {
|
|
|
286
272
|
empty: "empty";
|
|
287
273
|
basic: "basic";
|
|
288
274
|
}>>;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
sqlserver: "sqlserver";
|
|
298
|
-
cockroachdb: "cockroachdb";
|
|
299
|
-
}>>;
|
|
300
|
-
packageManager: zod.ZodOptional<zod.ZodEnum<{
|
|
301
|
-
npm: "npm";
|
|
302
|
-
pnpm: "pnpm";
|
|
303
|
-
bun: "bun";
|
|
304
|
-
}>>;
|
|
305
|
-
prismaPostgres: zod.ZodOptional<zod.ZodBoolean>;
|
|
306
|
-
databaseUrl: zod.ZodOptional<zod.ZodString>;
|
|
307
|
-
install: zod.ZodOptional<zod.ZodBoolean>;
|
|
308
|
-
generate: zod.ZodOptional<zod.ZodBoolean>;
|
|
309
|
-
schemaPreset: zod.ZodOptional<zod.ZodEnum<{
|
|
310
|
-
empty: "empty";
|
|
311
|
-
basic: "basic";
|
|
275
|
+
name: zod.ZodOptional<zod.ZodString>;
|
|
276
|
+
template: zod.ZodOptional<zod.ZodEnum<{
|
|
277
|
+
hono: "hono";
|
|
278
|
+
next: "next";
|
|
279
|
+
svelte: "svelte";
|
|
280
|
+
astro: "astro";
|
|
281
|
+
nuxt: "nuxt";
|
|
282
|
+
turborepo: "turborepo";
|
|
312
283
|
}>>;
|
|
284
|
+
skills: zod.ZodOptional<zod.ZodBoolean>;
|
|
285
|
+
mcp: zod.ZodOptional<zod.ZodBoolean>;
|
|
286
|
+
extension: zod.ZodOptional<zod.ZodBoolean>;
|
|
287
|
+
force: zod.ZodOptional<zod.ZodBoolean>;
|
|
313
288
|
}, zod_v4_core0.$strip>>, Schema<void, void>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
314
289
|
};
|
|
315
290
|
declare function createCreatePrismaCli(): trpc_cli0.TrpcCli;
|
|
316
|
-
declare function init(input?: InitCommandInput): Promise<void>;
|
|
317
291
|
declare function create(input?: CreateCommandInput): Promise<void>;
|
|
318
292
|
//#endregion
|
|
319
|
-
export { type CreateCommandInput, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema,
|
|
293
|
+
export { type CreateCommandInput, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema, PackageManagerSchema, SchemaPresetSchema, create, createCreatePrismaCli, router };
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-DgN5mAMV.mjs";
|
|
3
3
|
import { os } from "@orpc/server";
|
|
4
4
|
import { createCli } from "trpc-cli";
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const CLI_VERSION = "0.
|
|
8
|
-
const router = os.router({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}),
|
|
16
|
-
init: os.meta({
|
|
17
|
-
description: "Initialize Prisma in your current project",
|
|
18
|
-
negateBooleans: true
|
|
19
|
-
}).input(InitCommandInputSchema.optional()).handler(async ({ input }) => {
|
|
20
|
-
await runInitCommand(input ?? {});
|
|
21
|
-
})
|
|
22
|
-
});
|
|
7
|
+
const CLI_VERSION = "0.2.0";
|
|
8
|
+
const router = os.router({ create: os.meta({
|
|
9
|
+
description: "Create a new project with Prisma setup",
|
|
10
|
+
default: true,
|
|
11
|
+
negateBooleans: true
|
|
12
|
+
}).input(CreateCommandInputSchema.optional()).handler(async ({ input }) => {
|
|
13
|
+
await runCreateCommand(input ?? {});
|
|
14
|
+
}) });
|
|
23
15
|
function createCreatePrismaCli() {
|
|
24
16
|
return createCli({
|
|
25
17
|
router,
|
|
@@ -27,12 +19,9 @@ function createCreatePrismaCli() {
|
|
|
27
19
|
version: CLI_VERSION
|
|
28
20
|
});
|
|
29
21
|
}
|
|
30
|
-
async function init(input = {}) {
|
|
31
|
-
await runInitCommand(input);
|
|
32
|
-
}
|
|
33
22
|
async function create(input = {}) {
|
|
34
23
|
await runCreateCommand(input);
|
|
35
24
|
}
|
|
36
25
|
|
|
37
26
|
//#endregion
|
|
38
|
-
export { CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema,
|
|
27
|
+
export { CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, DatabaseUrlSchema, PackageManagerSchema, SchemaPresetSchema, create, createCreatePrismaCli, router };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-prisma",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Create
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Create Prisma 7 projects with first-party templates and great DX.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/prisma/create-prisma"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
Generated by `create-prisma` with the Astro template.
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
- `{{runScriptCommand packageManager "dev"}}` - start the Astro dev server
|
|
8
|
+
- `{{runScriptCommand packageManager "build"}}` - build for production
|
|
9
|
+
- `{{runScriptCommand packageManager "preview"}}` - preview the production build
|
|
10
|
+
- `{{runScriptCommand packageManager "astro"}}` - run Astro CLI commands
|
|
11
|
+
|
|
12
|
+
## Prisma
|
|
13
|
+
|
|
14
|
+
Prisma setup is scaffolded automatically in:
|
|
15
|
+
|
|
16
|
+
- `prisma/schema.prisma`
|
|
17
|
+
- `prisma/seed.ts`
|
|
18
|
+
- `src/lib/prisma.ts`
|
|
19
|
+
- `src/pages/api/users.ts`
|
|
20
|
+
- `prisma.config.ts`
|
|
21
|
+
- `src/generated/prisma`
|
|
22
|
+
|
|
23
|
+
Database helper scripts are added to `package.json`:
|
|
24
|
+
|
|
25
|
+
- `db:generate`
|
|
26
|
+
- `db:push`
|
|
27
|
+
- `db:migrate`
|
|
28
|
+
- `db:seed`
|
|
29
|
+
{{#if (eq schemaPreset "basic")}}
|
|
30
|
+
|
|
31
|
+
The starter page queries a basic `User` model in `src/pages/index.astro`, and `src/pages/api/users.ts` shows an Astro API route backed by the same Prisma client.
|
|
32
|
+
{{else}}
|
|
33
|
+
|
|
34
|
+
The starter page keeps the official Astro minimal structure and points you to `prisma/schema.prisma` for your first model.
|
|
35
|
+
{{/if}}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
{{#if (packageManagerManifestValue packageManager)}}
|
|
6
|
+
"packageManager": "{{packageManagerManifestValue packageManager}}",
|
|
7
|
+
{{/if}}
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "astro dev",
|
|
10
|
+
"build": "astro build",
|
|
11
|
+
"preview": "astro preview",
|
|
12
|
+
"astro": "astro"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"astro": "^5.17.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^24.3.0",
|
|
19
|
+
"tsx": "^4.7.1",
|
|
20
|
+
"typescript": "^5.9.3"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import prisma from "../src/lib/prisma";
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
{{#if (eq schemaPreset "basic")}}
|
|
5
|
+
const users = await Promise.all([
|
|
6
|
+
prisma.user.upsert({
|
|
7
|
+
where: { email: "alice@prisma.io" },
|
|
8
|
+
update: { name: "Alice" },
|
|
9
|
+
create: {
|
|
10
|
+
email: "alice@prisma.io",
|
|
11
|
+
name: "Alice",
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
prisma.user.upsert({
|
|
15
|
+
where: { email: "bob@prisma.io" },
|
|
16
|
+
update: { name: "Bob" },
|
|
17
|
+
create: {
|
|
18
|
+
email: "bob@prisma.io",
|
|
19
|
+
name: "Bob",
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
console.log(`Seeded ${users.length} users.`);
|
|
25
|
+
{{else}}
|
|
26
|
+
console.log("No seed data defined for the empty schema preset.");
|
|
27
|
+
{{/if}}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then(async () => {
|
|
32
|
+
await prisma.$disconnect();
|
|
33
|
+
})
|
|
34
|
+
.catch(async (error) => {
|
|
35
|
+
console.error(error);
|
|
36
|
+
await prisma.$disconnect();
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
|
|
2
|
+
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
|
|
3
|
+
<style>
|
|
4
|
+
path {
|
|
5
|
+
fill: #000;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@media (prefers-color-scheme: dark) {
|
|
9
|
+
path {
|
|
10
|
+
fill: #fff;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
</svg>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { PrismaClient } from "../generated/prisma/client";
|
|
3
|
+
{{#if (eq provider "postgresql")}}
|
|
4
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if (eq provider "cockroachdb")}}
|
|
7
|
+
import { PrismaPg } from "@prisma/adapter-pg";
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if (eq provider "mysql")}}
|
|
10
|
+
import { PrismaMariaDb } from "@prisma/adapter-mariadb";
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if (eq provider "sqlite")}}
|
|
13
|
+
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
|
|
14
|
+
{{/if}}
|
|
15
|
+
{{#if (eq provider "sqlserver")}}
|
|
16
|
+
import { PrismaMssql } from "@prisma/adapter-mssql";
|
|
17
|
+
{{/if}}
|
|
18
|
+
|
|
19
|
+
{{#if (eq provider "sqlite")}}
|
|
20
|
+
const databaseUrl =
|
|
21
|
+
import.meta.env?.DATABASE_URL ?? process.env.DATABASE_URL ?? "file:./dev.db";
|
|
22
|
+
{{else}}
|
|
23
|
+
const databaseUrl = import.meta.env?.DATABASE_URL ?? process.env.DATABASE_URL;
|
|
24
|
+
if (!databaseUrl) {
|
|
25
|
+
throw new Error("DATABASE_URL is required");
|
|
26
|
+
}
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
{{#if (eq provider "postgresql")}}
|
|
30
|
+
const adapter = new PrismaPg({
|
|
31
|
+
connectionString: databaseUrl,
|
|
32
|
+
});
|
|
33
|
+
{{/if}}
|
|
34
|
+
{{#if (eq provider "cockroachdb")}}
|
|
35
|
+
const adapter = new PrismaPg({
|
|
36
|
+
connectionString: databaseUrl,
|
|
37
|
+
});
|
|
38
|
+
{{/if}}
|
|
39
|
+
{{#if (eq provider "mysql")}}
|
|
40
|
+
const adapter = new PrismaMariaDb(databaseUrl);
|
|
41
|
+
{{/if}}
|
|
42
|
+
{{#if (eq provider "sqlite")}}
|
|
43
|
+
const adapter = new PrismaBetterSqlite3({
|
|
44
|
+
url: databaseUrl,
|
|
45
|
+
});
|
|
46
|
+
{{/if}}
|
|
47
|
+
{{#if (eq provider "sqlserver")}}
|
|
48
|
+
const adapter = new PrismaMssql(databaseUrl);
|
|
49
|
+
{{/if}}
|
|
50
|
+
|
|
51
|
+
const prisma = new PrismaClient({ adapter });
|
|
52
|
+
|
|
53
|
+
export default prisma;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { APIRoute } from "astro";
|
|
2
|
+
{{#if (eq schemaPreset "basic")}}
|
|
3
|
+
import prisma from "../../lib/prisma";
|
|
4
|
+
|
|
5
|
+
export const GET: APIRoute = async () => {
|
|
6
|
+
const users = await prisma.user
|
|
7
|
+
.findMany({
|
|
8
|
+
take: 10,
|
|
9
|
+
orderBy: {
|
|
10
|
+
createdAt: "desc",
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
.catch((error) => {
|
|
14
|
+
console.error("Failed to query users:", error);
|
|
15
|
+
return undefined;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (!users) {
|
|
19
|
+
return new Response(JSON.stringify({ error: "Could not query users yet." }), {
|
|
20
|
+
status: 500,
|
|
21
|
+
headers: {
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return new Response(JSON.stringify(users), {
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/json",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
{{else}}
|
|
34
|
+
|
|
35
|
+
export const GET: APIRoute = async () => {
|
|
36
|
+
return new Response(JSON.stringify([]), {
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
{{/if}}
|