Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DATABASE_URL=local.db
DATABASE_URL=local.db
JWT_SECRET=yoursecret
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="./static/logo.png" alt="PHp*" width="128" height="128">
<h1>PHp*</h1>

[Prisma](https://www.prisma.io/) + [Hono](https://hono.dev/) + [pnpm](https://pnpm.io/)
[Prisma](https://www.prisma.io/) + [Hono](https://hono.dev/) + [pnpm](https://pnpm.io/)

[![License](https://custom-icon-badges.demolab.com/github/license/bedtime-coders/phpstack?label=License&color=blue&logo=law&labelColor=0d1117&)](https://github.com/bedtime-coders/phpstack/blob/main/LICENSE)
[![Prisma](https://img.shields.io/badge/Prisma-2D3748?logo=prisma&logoColor=white)](https://www.prisma.io/)
Expand All @@ -13,9 +13,9 @@

</div>

## PHp*: Prisma + Hono + pnpm
## PHp\*: Prisma + Hono + pnpm

**PHp*** is a collection of bleeding-edge technologies to build modern web applications.
**PHp\*** is a collection of bleeding-edge technologies to build modern web applications.

Including:

Expand All @@ -37,19 +37,27 @@ Including:
cp .env.example .env
```

3. Push the database schema to the database
3. Start the database

```bash
pnpm db:dev
```

4. Update the .env file with your database URL given by the previous step, and your own JWT secret

5. Push the database schema to the database

```bash
pnpm db:push
```

4. Start the server
6. Start the server

```bash
pnpm dev
```

5. (Optional) Start the [database studio](https://www.prisma.io/studio)
7. (Optional) Start the [database studio](https://www.prisma.io/studio)
```bash
pnpm db:studio
```
Expand Down Expand Up @@ -80,4 +88,4 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information, including how to

---

<sup>*no relation to [PHP](https://www.php.net), the scripting language</sup>
<sup>\*no relation to [PHP](https://www.php.net), the scripting language</sup>
6 changes: 5 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
onlyBuiltDependencies:
- '@prisma/engines'
- "@prisma/engines"
- prisma

packages:
- "php"
- "php/src"
31 changes: 31 additions & 0 deletions src/articles/articles.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { z } from "@hono/zod-openapi";

export const CreateArticle = z.object({
article: z.object({
title: z.string(),
description: z.string(),
body: z.string(),
tagList: z.array(z.string()).optional(),
}),
});

export const UpdateArticle = z.object({
article: z.object({
title: z.string().optional(),
description: z.string().optional(),
body: z.string().optional(),
}),
});

export const FavoriteArticle = z.object({
slug: z.string(),
});

export const UnfavoriteArticle = z.object({
slug: z.string(),
});

export type CreateArticle = z.infer<typeof CreateArticle>;
export type UpdateArticle = z.infer<typeof UpdateArticle>;
export type FavoriteArticle = z.infer<typeof FavoriteArticle>;
export type UnfavoriteArticle = z.infer<typeof UnfavoriteArticle>;
Comment on lines +28 to +31
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Name collision: type aliases duplicate the const identifiers

A type and a const cannot share the exact same identifier; the code will not compile:

Duplicate identifier 'CreateArticle'.

Rename either the schemas or the inferred types. Minimal change:

-export const CreateArticle = z.object({ ... });
+export const CreateArticleSchema = z.object({ ... });

 // …

-export type CreateArticle = z.infer<typeof CreateArticle>;
-export type UpdateArticle = z.infer<typeof UpdateArticle>;
-export type FavoriteArticle = z.infer<typeof FavoriteArticle>;
-export type UnfavoriteArticle = z.infer<typeof UnfavoriteArticle>;
+export type CreateArticle = z.infer<typeof CreateArticleSchema>;
+export type UpdateArticle = z.infer<typeof UpdateArticleSchema>;
+export type FavoriteArticle = z.infer<typeof FavoriteArticleSchema>;
+export type UnfavoriteArticle = z.infer<typeof UnfavoriteArticleSchema>;

Alternatively, keep the constant names and append Type to the aliases.
Without this fix the module breaks the build.

🤖 Prompt for AI Agents
In src/articles/articles.schema.ts around lines 28 to 31, the type aliases
CreateArticle, UpdateArticle, FavoriteArticle, and UnfavoriteArticle have the
same names as their corresponding const schema identifiers, causing a duplicate
identifier error. To fix this, rename the type aliases by appending a suffix
like "Type" (e.g., CreateArticleType) to avoid name collisions while keeping the
const schema names unchanged.