Skip to content

Latest commit

 

History

History
102 lines (77 loc) · 1.76 KB

readme.md

File metadata and controls

102 lines (77 loc) · 1.76 KB

initialise the backend folder

 npm create hono@latest
Need to install the following packages:
[email protected]
Ok to proceed? (y) y


> npx
> create-hono

create-hono version 0.9.2
? Target directory backend
? Which template do you want to use? cloudflare-workers
✔ Cloning the template
? Do you want to install project dependencies? yes
? Which package manager do you want to use? npm
✔ Installing project dependencies
🎉 Copied project files
Get started with: cd backend

initialise the routes with appropriate methods

app.get("/", (c) => {
  return c.text("Hello Hono!");
});

app.post("/api/v1/user/signup", (c) => {
  return c.text("Hello Hono!");
});
app.post("/api/v1/user/signin", (c) => {
  return c.text("Hello Hono!");
});
app.post("/api/v1/blog", (c) => {
  return c.text("Hello Hono!");
});
app.put("/api/v1/blog", (c) => {
  return c.text("Hello Hono!");
});
app.get("/api/v1/blog/:id", (c) => {
  return c.text("Hello Hono!");
});
app.get("/api/v1/blog/bulk", (c) => {
  return c.text("Hello Hono!");
});
app.get("/api/v1/blog", (c) => {
  return c.text("Hello Hono from blog!");
});

to run the application

npm run dev

initialise prisma

npm i prisma
npx prisma init

cli will use .env file to connect to database, put database url in .env file backend utilise wrangler.toml to connect to database, prisma url in it

initialise the schema

migrate the database->

npx prisma migrate dev --name init_schema

generate prisma client->

npx prisma generate --no-engine

add the accelerate engine ->

npm install @prisma/extension-accelerate

initialise the prisma client

do the code generation

see we did the code in backend

now create a common folder

npm init -y
npx tsc --init