From 647e97101f04562faaaa29bbaa944a06507e1c33 Mon Sep 17 00:00:00 2001 From: Fractal-Tess Date: Tue, 11 Jun 2024 15:28:12 +0300 Subject: [PATCH] fixes --- .env | 5 +- .eslintrc.json | 2 +- .prettierrc.json | 9 ++ drizzle.config.ts | 12 +- drizzle/0005_chemical_phantom_reporter.sql | 1 + drizzle/0006_perpetual_alex_power.sql | 1 + drizzle/meta/0000_snapshot.json | 6 +- drizzle/meta/0001_snapshot.json | 10 +- drizzle/meta/0002_snapshot.json | 10 +- drizzle/meta/0003_snapshot.json | 14 +- drizzle/meta/0004_snapshot.json | 22 +-- drizzle/meta/0005_snapshot.json | 160 ++++++++++++++++++++ drizzle/meta/0006_snapshot.json | 161 +++++++++++++++++++++ drizzle/meta/_journal.json | 16 +- next.config.mjs | 2 +- package-lock.json | 109 +++++++++++++- package.json | 7 +- postcss.config.mjs | 4 +- src/app/about/page.tsx | 14 +- src/app/auth/activate/[token]/page.tsx | 8 +- src/app/blogs/[title]/page.tsx | 39 ++--- src/app/blogs/page.tsx | 29 ++-- src/app/globals.css | 2 +- src/app/layout.tsx | 30 ++-- src/app/login/page.tsx | 59 ++++---- src/app/page.tsx | 34 +++-- src/app/register/page.tsx | 70 +++++---- src/components/BlogsList.tsx | 12 +- src/components/Header.tsx | 14 +- src/db_connection.ts | 22 +-- src/env.ts | 40 +++++ src/lib/actions/login.ts | 50 +++---- src/lib/actions/register.ts | 28 ++-- src/schema.ts | 67 +++++---- tailwind.config.ts | 17 +-- 35 files changed, 802 insertions(+), 284 deletions(-) create mode 100644 .prettierrc.json create mode 100644 drizzle/0005_chemical_phantom_reporter.sql create mode 100644 drizzle/0006_perpetual_alex_power.sql create mode 100644 drizzle/meta/0005_snapshot.json create mode 100644 drizzle/meta/0006_snapshot.json create mode 100644 src/env.ts diff --git a/.env b/.env index 1c75cb2..fcf442d 100644 --- a/.env +++ b/.env @@ -1 +1,4 @@ -AUTH_SECRET=0cGJ5qnt9xRo2/E9cZB2TjUefAtz6B78+vItPv4DKPI= +DB_HOST=oracle.netbird.cloud +DB_USER=project-b +DB_PASSWORD=YCNeqYguf8K6yp +DB_DATABASE=project-b \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..4d765f2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,3 @@ { - "extends": "next/core-web-vitals" + "extends": ["next/core-web-vitals", "prettier"] } diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..656f6aa --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "trailingComma": "none", + "semi": true, + "tabWidth": 2, + "singleQuote": true, + "arrowParens": "avoid", + "jsxSingleQuote": true, + "plugins": ["prettier-plugin-tailwindcss"] +} diff --git a/drizzle.config.ts b/drizzle.config.ts index 142ee0b..478c903 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -1,3 +1,4 @@ +import { env } from '@/env'; import { defineConfig } from 'drizzle-kit'; export default defineConfig({ @@ -5,8 +6,9 @@ export default defineConfig({ out: './drizzle', dialect: 'mysql', dbCredentials: { - host: "localhost", - user: "root", - database: "projectb", - }, -}); \ No newline at end of file + host: env.DB_HOST, + user: env.DB_USER, + database: env.DB_DATABASE, + password: env.DB_PASSWORD + } +}); diff --git a/drizzle/0005_chemical_phantom_reporter.sql b/drizzle/0005_chemical_phantom_reporter.sql new file mode 100644 index 0000000..5194024 --- /dev/null +++ b/drizzle/0005_chemical_phantom_reporter.sql @@ -0,0 +1 @@ +ALTER TABLE `session` MODIFY COLUMN `userId` int NOT NULL; \ No newline at end of file diff --git a/drizzle/0006_perpetual_alex_power.sql b/drizzle/0006_perpetual_alex_power.sql new file mode 100644 index 0000000..3cb858e --- /dev/null +++ b/drizzle/0006_perpetual_alex_power.sql @@ -0,0 +1 @@ +ALTER TABLE `session` MODIFY COLUMN `timestamp` timestamp(6) DEFAULT (now()); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json index 1740960..603b509 100644 --- a/drizzle/meta/0000_snapshot.json +++ b/drizzle/meta/0000_snapshot.json @@ -34,9 +34,7 @@ "compositePrimaryKeys": { "blogs_id": { "name": "blogs_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -51,4 +49,4 @@ "tables": {}, "indexes": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json index e724d7d..af01a9c 100644 --- a/drizzle/meta/0001_snapshot.json +++ b/drizzle/meta/0001_snapshot.json @@ -34,9 +34,7 @@ "compositePrimaryKeys": { "blogs_id": { "name": "blogs_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -78,9 +76,7 @@ "compositePrimaryKeys": { "user_id": { "name": "user_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -95,4 +91,4 @@ "tables": {}, "indexes": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0002_snapshot.json b/drizzle/meta/0002_snapshot.json index da1b335..fc64363 100644 --- a/drizzle/meta/0002_snapshot.json +++ b/drizzle/meta/0002_snapshot.json @@ -34,9 +34,7 @@ "compositePrimaryKeys": { "blogs_id": { "name": "blogs_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -92,9 +90,7 @@ "compositePrimaryKeys": { "user_id": { "name": "user_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -109,4 +105,4 @@ "tables": {}, "indexes": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.json index 67f3fb6..0306a31 100644 --- a/drizzle/meta/0003_snapshot.json +++ b/drizzle/meta/0003_snapshot.json @@ -34,9 +34,7 @@ "compositePrimaryKeys": { "blogs_id": { "name": "blogs_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -71,9 +69,7 @@ "compositePrimaryKeys": { "session_id": { "name": "session_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -129,9 +125,7 @@ "compositePrimaryKeys": { "user_id": { "name": "user_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -146,4 +140,4 @@ "tables": {}, "indexes": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0004_snapshot.json b/drizzle/meta/0004_snapshot.json index bdcd4c5..0d931dd 100644 --- a/drizzle/meta/0004_snapshot.json +++ b/drizzle/meta/0004_snapshot.json @@ -34,9 +34,7 @@ "compositePrimaryKeys": { "blogs_id": { "name": "blogs_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -79,12 +77,8 @@ "name": "session_userId_user_id_fk", "tableFrom": "session", "tableTo": "user", - "columnsFrom": [ - "userId" - ], - "columnsTo": [ - "id" - ], + "columnsFrom": ["userId"], + "columnsTo": ["id"], "onDelete": "no action", "onUpdate": "no action" } @@ -92,9 +86,7 @@ "compositePrimaryKeys": { "session_id": { "name": "session_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -150,9 +142,7 @@ "compositePrimaryKeys": { "user_id": { "name": "user_id", - "columns": [ - "id" - ] + "columns": ["id"] } }, "uniqueConstraints": {} @@ -167,4 +157,4 @@ "tables": {}, "indexes": {} } -} \ No newline at end of file +} diff --git a/drizzle/meta/0005_snapshot.json b/drizzle/meta/0005_snapshot.json new file mode 100644 index 0000000..5d2dab8 --- /dev/null +++ b/drizzle/meta/0005_snapshot.json @@ -0,0 +1,160 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "bffda20b-2622-4b75-84ea-4fca92d7ef2b", + "prevId": "d5d66241-ba07-4c3c-b17f-effa97d48daf", + "tables": { + "blogs": { + "name": "blogs", + "columns": { + "id": { + "name": "id", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "blogs_id": { + "name": "blogs_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "token": { + "name": "token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "userId": { + "name": "userId", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp(6)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "session_userId_user_id_fk": { + "name": "session_userId_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "session_id": { + "name": "session_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "email": { + "name": "email", + "type": "varchar(320)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "activationToken": { + "name": "activationToken", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_id": { + "name": "user_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {} + } + }, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/drizzle/meta/0006_snapshot.json b/drizzle/meta/0006_snapshot.json new file mode 100644 index 0000000..f7be190 --- /dev/null +++ b/drizzle/meta/0006_snapshot.json @@ -0,0 +1,161 @@ +{ + "version": "5", + "dialect": "mysql", + "id": "e6fc5081-7c31-4b2a-9f6f-14fb500feb3f", + "prevId": "bffda20b-2622-4b75-84ea-4fca92d7ef2b", + "tables": { + "blogs": { + "name": "blogs", + "columns": { + "id": { + "name": "id", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "blogs_id": { + "name": "blogs_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "token": { + "name": "token", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "userId": { + "name": "userId", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp(6)", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "(now())" + } + }, + "indexes": {}, + "foreignKeys": { + "session_userId_user_id_fk": { + "name": "session_userId_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": ["userId"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "session_id": { + "name": "session_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "int", + "primaryKey": false, + "notNull": true, + "autoincrement": true + }, + "email": { + "name": "email", + "type": "varchar(320)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "activationToken": { + "name": "activationToken", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "user_id": { + "name": "user_id", + "columns": ["id"] + } + }, + "uniqueConstraints": {} + } + }, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": {}, + "indexes": {} + } +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 09e1e41..5d16cd0 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -36,6 +36,20 @@ "when": 1718026902741, "tag": "0004_thin_redwing", "breakpoints": true + }, + { + "idx": 5, + "version": "5", + "when": 1718107769018, + "tag": "0005_chemical_phantom_reporter", + "breakpoints": true + }, + { + "idx": 6, + "version": "5", + "when": 1718108211555, + "tag": "0006_perpetual_alex_power", + "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/next.config.mjs b/next.config.mjs index 13928e0..aed5ac3 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,6 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - output: "standalone" + output: 'standalone' }; export default nextConfig; diff --git a/package-lock.json b/package-lock.json index c60a774..dde5ca3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "project-b", "version": "0.1.0", "dependencies": { + "@t3-oss/env-core": "^0.10.1", "drizzle-orm": "^0.31.1", "mysql2": "^3.10.0", "next": "14.2.3", @@ -25,6 +26,8 @@ "eslint": "^8", "eslint-config-next": "14.2.3", "postcss": "^8", + "prettier": "^3.3.2", + "prettier-plugin-tailwindcss": "^0.6.2", "tailwindcss": "^3.4.1", "typescript": "^5", "zod": "^3.23.8" @@ -1264,6 +1267,20 @@ "tslib": "^2.4.0" } }, + "node_modules/@t3-oss/env-core": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@t3-oss/env-core/-/env-core-0.10.1.tgz", + "integrity": "sha512-GcKZiCfWks5CTxhezn9k5zWX3sMDIYf6Kaxy2Gx9YEQftFcz8hDRN56hcbylyAO3t4jQnQ5ifLawINsNgCDpOg==", + "peerDependencies": { + "typescript": ">=5.0.0", + "zod": "^3.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@types/cookie": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", @@ -4873,6 +4890,95 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-tailwindcss": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.2.tgz", + "integrity": "sha512-eFefm4cg+1c2B57+H274Qm//CTWBdtQN9ansl0YTP/8TC8x3bugCTQSS/e4FC5Ctl9djhTzsbcMrZ7x2/abIow==", + "dev": true, + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "@ianvs/prettier-plugin-sort-imports": "*", + "@prettier/plugin-pug": "*", + "@shopify/prettier-plugin-liquid": "*", + "@trivago/prettier-plugin-sort-imports": "*", + "@zackad/prettier-plugin-twig-melody": "*", + "prettier": "^3.0", + "prettier-plugin-astro": "*", + "prettier-plugin-css-order": "*", + "prettier-plugin-import-sort": "*", + "prettier-plugin-jsdoc": "*", + "prettier-plugin-marko": "*", + "prettier-plugin-organize-attributes": "*", + "prettier-plugin-organize-imports": "*", + "prettier-plugin-sort-imports": "*", + "prettier-plugin-style-order": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "@ianvs/prettier-plugin-sort-imports": { + "optional": true + }, + "@prettier/plugin-pug": { + "optional": true + }, + "@shopify/prettier-plugin-liquid": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@zackad/prettier-plugin-twig-melody": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-css-order": { + "optional": true + }, + "prettier-plugin-import-sort": { + "optional": true + }, + "prettier-plugin-jsdoc": { + "optional": true + }, + "prettier-plugin-marko": { + "optional": true + }, + "prettier-plugin-organize-attributes": { + "optional": true + }, + "prettier-plugin-organize-imports": { + "optional": true + }, + "prettier-plugin-sort-imports": { + "optional": true + }, + "prettier-plugin-style-order": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, "node_modules/pretty-format": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-3.8.0.tgz", @@ -5793,7 +5899,7 @@ "version": "5.4.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", - "dev": true, + "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -6069,7 +6175,6 @@ "version": "3.23.8", "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", - "dev": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/package.json b/package.json index d1ce546..9c7604d 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,17 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev", + "dev": "next dev --turbo", "build": "next build", "start": "next start", "lint": "next lint", + "format": "prettier --check --ignore-path .gitignore .", + "format:fix": "prettier --write --ignore-path .gitignore .", "generate": "drizzle-kit generate", "migrate": "drizzle-kit migrate" }, "dependencies": { + "@t3-oss/env-core": "^0.10.1", "drizzle-orm": "^0.31.1", "mysql2": "^3.10.0", "next": "14.2.3", @@ -29,6 +32,8 @@ "eslint": "^8", "eslint-config-next": "14.2.3", "postcss": "^8", + "prettier": "^3.3.2", + "prettier-plugin-tailwindcss": "^0.6.2", "tailwindcss": "^3.4.1", "typescript": "^5", "zod": "^3.23.8" diff --git a/postcss.config.mjs b/postcss.config.mjs index 1a69fd2..df76ed2 100644 --- a/postcss.config.mjs +++ b/postcss.config.mjs @@ -1,8 +1,8 @@ /** @type {import('postcss-load-config').Config} */ const config = { plugins: { - tailwindcss: {}, - }, + tailwindcss: {} + } }; export default config; diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx index 29f57fd..22d0fda 100644 --- a/src/app/about/page.tsx +++ b/src/app/about/page.tsx @@ -1,9 +1,9 @@ -import React from "react"; +import React from 'react'; export default function About() { - return ( -
- Hello from the about page -
- ) -} \ No newline at end of file + return ( +
+ Hello from the about page +
+ ); +} diff --git a/src/app/auth/activate/[token]/page.tsx b/src/app/auth/activate/[token]/page.tsx index d3e5962..5ffbc77 100644 --- a/src/app/auth/activate/[token]/page.tsx +++ b/src/app/auth/activate/[token]/page.tsx @@ -1,5 +1,5 @@ -import { db } from "@/db_connection"; -import * as schema from "@/schema"; +import { db } from '@/db_connection'; +import * as schema from '@/schema'; type Props = { params: { @@ -9,7 +9,7 @@ type Props = { export default async function Page(props: Props) { const user = await db.query.user.findFirst({ - where: (user, { eq }) => eq(user.activationToken, props.params.token), + where: (user, { eq }) => eq(user.activationToken, props.params.token) }); if (!user) { @@ -22,7 +22,7 @@ export default async function Page(props: Props) { await db.update(schema.user).set({ activationToken: null, - verified: true, + verified: true }); return ( diff --git a/src/app/blogs/[title]/page.tsx b/src/app/blogs/[title]/page.tsx index 9919487..5213c69 100644 --- a/src/app/blogs/[title]/page.tsx +++ b/src/app/blogs/[title]/page.tsx @@ -1,22 +1,27 @@ -import { db } from "@/db_connection" -import { redirect } from "next/navigation" - +import { db } from '@/db_connection'; +import { redirect } from 'next/navigation'; type Props = { - params: { - title: string - } -} + params: { + title: string; + }; +}; -export default async function Page({params}:Props) { - const blog = await db.query.blog.findFirst({where:(blog, {eq}) => { - return eq(blog.title, params.title) - }}) - - if (!blog) { - redirect("/blogs") +export default async function Page({ params }: Props) { + const blog = await db.query.blog.findFirst({ + where: (blog, { eq }) => { + return eq(blog.title, params.title); } - return <> -

{params.title} {blog?.content}

+ }); + + if (!blog) { + redirect('/blogs'); + } + return ( + <> +

+ {params.title} {blog?.content} +

-} \ No newline at end of file + ); +} diff --git a/src/app/blogs/page.tsx b/src/app/blogs/page.tsx index 4ec0645..1c4cb09 100644 --- a/src/app/blogs/page.tsx +++ b/src/app/blogs/page.tsx @@ -1,19 +1,18 @@ -import React, { useEffect, useState } from "react"; -import { db } from "@/db_connection"; -import BlogsList from "@/components/BlogsList"; +import React, { useEffect, useState } from 'react'; +import { db } from '@/db_connection'; +import BlogsList from '@/components/BlogsList'; export default async function Page() { - const blogsfromdb = await db.query.blog.findMany(); + const blogsfromdb = await db.query.blog.findMany(); - - return ( - <> -
-

Blogs

- -
- - ) + return ( + <> +
+

Blogs

+ +
+ + ); } diff --git a/src/app/globals.css b/src/app/globals.css index bd6213e..b5c61c9 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -1,3 +1,3 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 5bae663..b4c37dc 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,29 +1,29 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "./globals.css"; -import React from "react"; -import Header from "@/components/Header"; -import { db } from "@/db_connection"; +import type { Metadata } from 'next'; +import { Inter } from 'next/font/google'; +import './globals.css'; +import React from 'react'; +import Header from '@/components/Header'; +import { db } from '@/db_connection'; -const inter = Inter({ subsets: ["latin"] }); +const inter = Inter({ subsets: ['latin'] }); export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: 'Create Next App', + description: 'Generated by create next app' }; export default function RootLayout({ - children, + children }: Readonly<{ children: React.ReactNode; }>) { return ( - - + +
-
{children}
+
+ {children} +
); diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx index 62c3230..add1714 100644 --- a/src/app/login/page.tsx +++ b/src/app/login/page.tsx @@ -1,46 +1,51 @@ -"use client" -import { login } from "@/lib/actions/login"; -import { useFormState } from "react-dom"; +'use client'; +import { login } from '@/lib/actions/login'; +import { useFormState } from 'react-dom'; const initialState = { - message: "" -} + message: '' +}; export default function Page() { - "use client" - const [state, formAction] = useFormState(login, initialState) + 'use client'; + const [state, formAction] = useFormState(login, initialState); return ( -
-
-