This is a Medium Blog project built with TypeScript, Prisma, and Hono, deployed on Cloudflare Workers.
medium-blog/
├── backend/
│ ├── src/
│ │ ├── controllers/
│ │ │ └── blogControllers.ts
│ │ ├── types/
│ │ │ ├── blogTypes.ts
│ │ │ ├── envTypes.ts
│ │ │ └── zodSchema.ts
│ │ ├── utils/
│ │ │ └── sendResponse.ts
│ │ └── index.ts
│ └── prisma/
│ └── schema.prisma
├── frontend/
│ └── ...
└── README.md
- Node.js
- pnpm
- Prisma
- Cloudflare Workers
-
Install dependencies:
pnpm install
-
Set up the database:
Make sure you have a PostgreSQL database running and update the
DATABASE_URLin your.envfile. -
Run Prisma migrations:
pnpm prisma migrate dev --name init
-
Deploy to Cloudflare Workers:
Ensure you have the Cloudflare Workers CLI (
wrangler) installed. If not, install it using:pnpm install -g wrangler
Then, configure your Cloudflare Workers project by running:
wrangler login wrangler init
Finally, deploy your project:
wrangler publish
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
pnpm install
-
Start the frontend server:
pnpm start
-
URL:
/api/blogs -
Method:
POST -
Request Body:
{ "title": "Blog Title", "content": "Blog Content", "published": true } -
Response:
{ "success": true, "data": { "id": 1, "title": "Blog Title", "content": "Blog Content", "published": true, "authorId": 1 } }
- URL:
/api/blogs/:id - Method:
PUT - Request Body: (similar to create)
-
URL:
/api/blogs -
Method:
GET -
Response:
{ "success": true, "data": [ { "id": 1, "title": "Blog Title", "content": "Blog Content", "published": true, "authorId": 1 } ] }
- Framework: Hono
- Database: PostgreSQL
- ORM: Prisma
- Deployment: Cloudflare Workers
- Framework: React JS