Skip to content

Commit

Permalink
fixed error and created blogCard
Browse files Browse the repository at this point in the history
  • Loading branch information
krishna9358 committed Aug 18, 2024
1 parent dc6c599 commit 6d846cf
Show file tree
Hide file tree
Showing 3,802 changed files with 655,145 additions and 2,690,052 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 6 additions & 6 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://"
18 changes: 9 additions & 9 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
node_modules
dist
.wrangler
.dev.vars

# Change them to your taste:
package-lock.json
yarn.lock
pnpm-lock.yaml
node_modules
dist
.wrangler
.dev.vars

# Change them to your taste:
package-lock.json
yarn.lock
pnpm-lock.yaml
bun.lockb
16 changes: 8 additions & 8 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
```
npm install
npm run dev
```

```
npm run deploy
```
```
npm install
npm run dev
```

```
npm run deploy
```
38 changes: 19 additions & 19 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"scripts": {
"dev": "wrangler dev src/index.ts",
"deploy": "wrangler deploy --minify src/index.ts"
},
"dependencies": {
"@krishna7060/common": "^1.0.0",
"@prisma/client": "^5.14.0",
"@prisma/extension-accelerate": "^1.0.0",
"hono": "^4.3.8",
"prisma": "^5.14.0",
"yarn": "^1.22.22"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240403.0",
"@types/node": "^20.12.12",
"wrangler": "^3.57.2"
}
}
{
"scripts": {
"dev": "wrangler dev src/index.ts",
"deploy": "wrangler deploy --minify src/index.ts"
},
"dependencies": {
"@krishna7060/common": "^1.0.0",
"@prisma/client": "^5.14.0",
"@prisma/extension-accelerate": "^1.0.0",
"hono": "^4.3.8",
"prisma": "^5.14.0",
"yarn": "^1.22.22"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240403.0",
"@types/node": "^20.12.12",
"wrangler": "^3.57.2"
}
}
52 changes: 26 additions & 26 deletions backend/prisma/migrations/20240522173045_first_model/migration.sql
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"name" TEXT,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Blog" (
"id" SERIAL NOT NULL,
"authorId" INTEGER NOT NULL,
"content" TEXT NOT NULL,
"title" TEXT NOT NULL,
"published" BOOLEAN NOT NULL DEFAULT false,

CONSTRAINT "Blog_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

-- AddForeignKey
ALTER TABLE "Blog" ADD CONSTRAINT "Blog_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"name" TEXT,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Blog" (
"id" SERIAL NOT NULL,
"authorId" INTEGER NOT NULL,
"content" TEXT NOT NULL,
"title" TEXT NOT NULL,
"published" BOOLEAN NOT NULL DEFAULT false,

CONSTRAINT "Blog_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");

-- AddForeignKey
ALTER TABLE "Blog" ADD CONSTRAINT "Blog_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
4 changes: 2 additions & 2 deletions backend/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
66 changes: 33 additions & 33 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
name String?
username String @unique
password String
blog Blog[]
}


model Blog{
id Int @id @default(autoincrement())
authorId Int
content String
title String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
}

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
name String?
username String @unique
password String
blog Blog[]
}


model Blog{
id Int @id @default(autoincrement())
authorId Int
content String
title String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
}

52 changes: 26 additions & 26 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { Hono } from 'hono'
import userRouter from './routes/userRouter';
import { blogRouter } from './routes/blogRouter';
import { cors } from 'hono/cors';


// const prisma = new PrismaClient({ this should be initilize in each and evry route for
// datasourceUrl: env.DATABASE_URL,
// }).$extends(withAccelerate())

// <{
// Bindings: { defining the type
// DATABASE_URL: string
// }
// }>

const app = new Hono()
app.use('/*', cors())
app.route("/api/v1/user", userRouter);
app.route("/api/v1/blog", blogRouter);

app.get('/', (c) => {

return c.text('Hello Hono!')
})

import { Hono } from 'hono'
import userRouter from './routes/userRouter';
import { blogRouter } from './routes/blogRouter';
import { cors } from 'hono/cors';


// const prisma = new PrismaClient({ this should be initilize in each and evry route for
// datasourceUrl: env.DATABASE_URL,
// }).$extends(withAccelerate())

// <{
// Bindings: { defining the type
// DATABASE_URL: string
// }
// }>

const app = new Hono()
app.use('/*', cors())
app.route("/api/v1/user", userRouter);
app.route("/api/v1/blog", blogRouter);

app.get('/', (c) => {

return c.text('Hello Hono!')
})

export default app
2 changes: 1 addition & 1 deletion backend/src/routes/userRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ userRouter.post('/signup',async (c) => {

userRouter.post('/signin', async (c) => {
const body = await c.req.json();
const {success} = signupInput.safeParse(body);
const {success} = LoginInput.safeParse(body);
if(!success) {
c.status(411)
return c.json({
Expand Down
32 changes: 16 additions & 16 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": [
"ESNext"
],
"types": [
"@cloudflare/workers-types"
],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
},
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": [
"ESNext"
],
"types": [
"@cloudflare/workers-types"
],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
},
}
46 changes: 23 additions & 23 deletions backend/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name = "backend"
compatibility_date = "2023-12-01"

[vars]
# MY_VAR = "my-variable"
DATABASE_URL="prisma://accelerate.prisma-data.net/"
JWT_SECRET=""


# [[kv_namespaces]]
# binding = "MY_KV_NAMESPACE"
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# [[r2_buckets]]
# binding = "MY_BUCKET"
# bucket_name = "my-bucket"

# [[d1_databases]]
# binding = "DB"
# database_name = "my-database"
# database_id = ""

# [ai]
name = "backend"
compatibility_date = "2023-12-01"

[vars]
# MY_VAR = "my-variable"
DATABASE_URL="prisma://accelerate.prisma-data.net/"
JWT_SECRET=""


# [[kv_namespaces]]
# binding = "MY_KV_NAMESPACE"
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

# [[r2_buckets]]
# binding = "MY_BUCKET"
# bucket_name = "my-bucket"

# [[d1_databases]]
# binding = "DB"
# database_name = "my-database"
# database_id = ""

# [ai]
# binding = "AI"
Loading

0 comments on commit 6d846cf

Please sign in to comment.