This project is a comprehensive backend system designed to manage blog content. It is built to be scalable and secure, leveraging cloud technologies and modern development practices.
- Prisma: ORM for database operations, configured for connection pooling and optimized with an acceleration layer.
- Hono: A minimal and fast framework for building web applications.
- Cloudflare Workers: Used for deploying the backend, ensuring high availability and low latency.
- JWT: For secure authentication.
- Zod: For validation of request data to ensure data integrity and security.
- npm: For package management and distribution.
To get started with this project, follow these steps:
- Clone the repository to your local machine.
- Install dependencies using
npm install
. - Set up environment variables for
DATABASE_URL
andJWT_SECRET
in your environment or a.env
file. -> prisma --> db url -> wrangler --> accelerate url - Run local development server using
npm run dev
.
- Log in to your Cloudflare account using
npx wrangler login
. - Verify your identity with
npx wrangler whoami
. - Deploy your application using
npm run deploy
.
- Update the
package.json
with your username and desired package name. - Log in to npm using
npm login
. - Publish your package with
npm publish --access public
ornpm publish --access private
for private packages.
- src/
- routes/: Contains the router files like
blogRouter.ts
which handle blog-related routes. - prisma/: Prisma schema and configuration files.
- middlewares/: Middleware functions for authentication and other purposes.
- validation/: Zod schemas for input validation.
- routes/: Contains the router files like
- common/: Common utilities and types, published as an npm package for reuse.
- JWT-based authorization.
- CRUD operations for blog posts.
- Input validation using Zod.
- Accelerated database operations with Prisma and Cloudflare Workers.
- Integration of frontend components.
- Expansion of the API to include more features such as comments and user profiles.
- Enhanced error handling and logging mechanisms.
// db initialization neon.tech // connectoin pooling using accelerated prisma //initialization of prisma // prisma schema // routes hono // added jwt authorization // added middlewares // zod validation || common folder and zod validation // zod types // publish common folder to npm and used
// create react app // create routes // create pages // create components // backend call, and jwt for signup and signnin // local storage jwt when signun and login // signup sign in page // blogs page -> blog component // app bar -> login and user logo dashboard // fetch all blogs from database using custom hook/recoil //
- can view blogs by directly using url
- password are not hashed in database.
// Note : start doing the frontend wala part from starting . Download the files to copy paste and fix the ui/ux for fast work. Backend is clear.
//demo password { "username" : "[email protected]", "password" : "123455678" }