pradeep
pradeep
Explore posts from servers
TTCTheo's Typesafe Cult
Created by pradeep on 2/17/2024 in #questions
Video Transcoding Service
No description
2 replies
CDCloudflare Developers
Created by pradeep on 12/28/2023 in #general-help
cloudflare polish
Is cloudflare polish free with a pro plan?
3 replies
TTCTheo's Typesafe Cult
Created by pradeep on 9/19/2023 in #questions
responsiveness with object using tailwind
hello guys i am trying to achieve responsiveness in tailwind with the help of js object example:-
const className={
sm:"bg-blue-300",
md:"bg-red-500",
}
const className={
sm:"bg-blue-300",
md:"bg-red-500",
}
will be converted on
const convertedClassName="sm:bg-blue-300 md:bg-red-500"
const convertedClassName="sm:bg-blue-300 md:bg-red-500"
because of dynamic class name (https://tailwindcss.com/docs/content-configuration#dynamic-class-names) i cannot write a function in javascript can anyone suggest me library which do the same thing or anything which will help me to remove this problem
10 replies
TTCTheo's Typesafe Cult
Created by pradeep on 8/16/2023 in #questions
t3-env is giving error module is not defined in ES module scope
i am trying to add t3-env in my project and it is giving me error
- error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error

> Build error occurred
ReferenceError: module is not defined in ES module scope
at file:///C:/Users/new/Documents/resume-builder/next.config.mjs:5:1
- error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error

> Build error occurred
ReferenceError: module is not defined in ES module scope
at file:///C:/Users/new/Documents/resume-builder/next.config.mjs:5:1
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noUncheckedIndexedAccess": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"tsconfig.json",
"**/*.mjs"
],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noUncheckedIndexedAccess": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"tsconfig.json",
"**/*.mjs"
],
"exclude": ["node_modules"]
}
next.config.mjs
await import('./src/env.mjs');
/** @type {import('next').NextConfig} */
const nextConfig = {};
module.exports = nextConfig;
await import('./src/env.mjs');
/** @type {import('next').NextConfig} */
const nextConfig = {};
module.exports = nextConfig;
please help me with this i am unable to find how to resolve this error
6 replies
TTCTheo's Typesafe Cult
Created by pradeep on 8/1/2023 in #questions
Stale dynamic sitemap
I am trying to create dynamic sitemap but after first time it is not updating the sitemap can anyone help me fix this issue? code:-https://github.com/pradeep800/striver-sheet-webiste/blob/main/app/sitemap.ts
2 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/12/2023 in #questions
dates are not same in server and client(dayjs)
currentDate = new Date();
const options = { timeZone: "Asia/Kolkata" };
const indianDateAndTime = currentDate.toLocaleString("en-US", options);
const indianDate = indianDateAndTime.substring(0, 9) as string;
const date = dayjs.tz(indianDate, "Asia/Kolkata");
const minDate = date.add(minReminderRange, "day").toDate();

const maxDate = date.add(maxReminderRange, "day").toDate();
console.log(maxDate.toISOString(), minDate.toISOString());
currentDate = new Date();
const options = { timeZone: "Asia/Kolkata" };
const indianDateAndTime = currentDate.toLocaleString("en-US", options);
const indianDate = indianDateAndTime.substring(0, 9) as string;
const date = dayjs.tz(indianDate, "Asia/Kolkata");
const minDate = date.add(minReminderRange, "day").toDate();

const maxDate = date.add(maxReminderRange, "day").toDate();
console.log(maxDate.toISOString(), minDate.toISOString());
this is giving output in client as 2023-08-07T13:00:00.000Z 2023-07-12T13:00:00.000Z output in server 2023-08-07T18:30:00.000Z 2023-07-12T18:30:00.000Z can anyone tell me why it is happening
15 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/11/2023 in #questions
working with datetime in drizzle
Problem:- I don’t know what date time is working in drizzle
Drizzle schema export const reminders = mysqlTable( "reminders", { id: int("id").notNull().autoincrement().primaryKey(), created_at: timestamp("created_at").defaultNow(), due_date: datetime("due_time").notNull(), should_send_mail: boolean("should_send_mail"), mail_sended: boolean("mail_sended").default(false), user_id: varchar("user_id", { length: 255, }).notNull(), question_no: int("question_no").notNull(), }, (reminder) => ({ ReminderCreatorIdIndex: index("reminder_creator_id_index").on( reminder.user_id ), }) ); I am giving drizzle reminderData: { dueDate: 2023-07-11T18:30:00.000Z, shouldSendMail: true } this value and drizzle is storing these value {"id":21,"created_at":"2023-07-11T17:21:35.000Z","due_date":"2023-07-11T13:00:00.000Z","should_send_mail":true,"mail_sended":false,"user_id":"dfc468c8-d3c7-4385-904b-6c40aa699104","question_no":2 Why there is difference can anyone tell me what is problem
2 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/10/2023 in #questions
open graph is not working
open graph is not working in next js 13 because it is not getting server rendered metadata can anyone tell me how can i server render my open graph in metatag website :- https://striversheet.pradeepbisht.com/ github :-https://github.com/pradeep800/striver-sheet-webiste/blob/main/app/layout.tsx if you check view page source it is adding script tag whcih should not be the case it should send html can someone tell me how i can i make this metatag render on server side
4 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/10/2023 in #questions
throwing error is server action is not working in production
i am trying to throw error from server action and catching it in client it is working on development but it is not in production it is giving me given below error:- An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error. code is basically this :-
"use server"
export function action(){
if(somethingWentWrong)
throw new Error("unable to perform this task");
return ....;
}
"use server"
export function action(){
if(somethingWentWrong)
throw new Error("unable to perform this task");
return ....;
}
in client side ```js "use client" function Compo(){ async function onClick(){ try{ await action(); }catch(err){ console.log(err.message); } ///...some things render } can anyone tell me why?
2 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/9/2023 in #questions
how can modify cookies in route handler with server action
let say we have page route
export defualt function Page(){
const user=await getUser();
if(!user){
/*
serversignout is server action which implements a another page
*/
serversignout();
redirect("/login");
}
return <div>my page</div>
}
export defualt function Page(){
const user=await getUser();
if(!user){
/*
serversignout is server action which implements a another page
*/
serversignout();
redirect("/login");
}
return <div>my page</div>
}
server signout is implemented as given below
"use server"
//necessary imports
export async function serversignout() {
const cookiesStore = cookies();
const csrf = cookiesStore.get("next-auth.csrf-token");
cookies().set({
name: "next-auth.csrf-token",
value: "",
expires: new Date("2016-10-05"),
path: "/", // For all paths
});
cookies().set({
name: "next-auth.callback-url",
value: "",
expires: new Date("2016-10-05"),
path: "/", // For all paths
});
cookies().set({
name: "next-auth.session-token",
value: "",
expires: new Date("2016-10-05"),
path: "/", // For all paths
});

console.log(csrf);
await fetch(absoluteUrl("/api/auth/signout"), {
cache: "no-cache",
method: "POST",
body: JSON.stringify({ csrfToken: csrf?.value }),
});
}
"use server"
//necessary imports
export async function serversignout() {
const cookiesStore = cookies();
const csrf = cookiesStore.get("next-auth.csrf-token");
cookies().set({
name: "next-auth.csrf-token",
value: "",
expires: new Date("2016-10-05"),
path: "/", // For all paths
});
cookies().set({
name: "next-auth.callback-url",
value: "",
expires: new Date("2016-10-05"),
path: "/", // For all paths
});
cookies().set({
name: "next-auth.session-token",
value: "",
expires: new Date("2016-10-05"),
path: "/", // For all paths
});

console.log(csrf);
await fetch(absoluteUrl("/api/auth/signout"), {
cache: "no-cache",
method: "POST",
body: JSON.stringify({ csrfToken: csrf?.value }),
});
}
can anyone tell me why it is giving error in production as ReadonlyRequestCookiesError: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options please help
1 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/9/2023 in #questions
signout from server in next js 13
can anyone tell me how can i signout from server in next auth? signOut() is not working and below code is also not working(i am using this inside server action
cookies().set({
name: "next-auth.csrf-token",
maxAge: 0,
value: "",
httpOnly: true,
sameSite: "lax",
priority: "medium",
domain: "/",
});
cookies().set({
name: "next-auth.callback-url",
maxAge: 0,
value: "",
sameSite: "lax",
priority: "medium",
httpOnly: true,
domain: "/",
});
cookies().set({
name: "next-auth.session-token",
maxAge: 0,
value: "",
sameSite: "lax",
priority: "medium",

httpOnly: true,

domain: "/",
});
cookies().set({
name: "next-auth.csrf-token",
maxAge: 0,
value: "",
httpOnly: true,
sameSite: "lax",
priority: "medium",
domain: "/",
});
cookies().set({
name: "next-auth.callback-url",
maxAge: 0,
value: "",
sameSite: "lax",
priority: "medium",
httpOnly: true,
domain: "/",
});
cookies().set({
name: "next-auth.session-token",
maxAge: 0,
value: "",
sameSite: "lax",
priority: "medium",

httpOnly: true,

domain: "/",
});
6 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/8/2023 in #questions
Promise.all is not working in transaction in drizzle
Can anyone tell me why this transaction is not working in drizzle? it does not throwing any error but it is not deleting it either
"use server";

import { authOption } from "@/lib/auth";
import { db } from "@/lib/db";
import * as schema from "@/lib/db/schema";
import { eq } from "drizzle-orm";
import { getServerSession } from "next-auth";
import { zact } from "zact/server";

export const deleteAccount = zact()(async () => {
const session = await getServerSession(authOption);
if (!session || !session.user) {
throw new Error("Unauthorized");
}
const userId = session.user.id;

try {
const [userInfo] = await db
.select({ sheeId: schema.users.id, email: schema.users.email })
.from(schema.users)
.where(eq(schema.users.id, userId))
.limit(1);
const sheetId = userInfo.sheeId as string;
await db.transaction(async (tx) => {
//delete all users
const deleteUser = tx
.delete(schema.users)
.where(eq(schema.users.id, userId));

//delete all accounts
const deleteAccounts = tx
.delete(schema.accounts)
.where(eq(schema.accounts.userId, userId));

//delete all sessions
const deleteSessions = tx
.delete(schema.sessions)
.where(eq(schema.sessions.userId, userId));

//delete all question solved
const deleteQuestions = tx
.delete(schema.questions)
.where(eq(schema.questions.sheet_id, sheetId));

///remove all tracking questions
const deleteTrackingQuestions = tx
.delete(schema.trackingQuestions)
.where(eq(schema.trackingQuestions.userId, userId));

//remove all verification token
const deleteVerificationTokens = tx
.delete(schema.verificationTokens)
.where(
eq(schema.verificationTokens.identifier, userInfo.email as string)
);

//remove all reminders

"use server";

import { authOption } from "@/lib/auth";
import { db } from "@/lib/db";
import * as schema from "@/lib/db/schema";
import { eq } from "drizzle-orm";
import { getServerSession } from "next-auth";
import { zact } from "zact/server";

export const deleteAccount = zact()(async () => {
const session = await getServerSession(authOption);
if (!session || !session.user) {
throw new Error("Unauthorized");
}
const userId = session.user.id;

try {
const [userInfo] = await db
.select({ sheeId: schema.users.id, email: schema.users.email })
.from(schema.users)
.where(eq(schema.users.id, userId))
.limit(1);
const sheetId = userInfo.sheeId as string;
await db.transaction(async (tx) => {
//delete all users
const deleteUser = tx
.delete(schema.users)
.where(eq(schema.users.id, userId));

//delete all accounts
const deleteAccounts = tx
.delete(schema.accounts)
.where(eq(schema.accounts.userId, userId));

//delete all sessions
const deleteSessions = tx
.delete(schema.sessions)
.where(eq(schema.sessions.userId, userId));

//delete all question solved
const deleteQuestions = tx
.delete(schema.questions)
.where(eq(schema.questions.sheet_id, sheetId));

///remove all tracking questions
const deleteTrackingQuestions = tx
.delete(schema.trackingQuestions)
.where(eq(schema.trackingQuestions.userId, userId));

//remove all verification token
const deleteVerificationTokens = tx
.delete(schema.verificationTokens)
.where(
eq(schema.verificationTokens.identifier, userInfo.email as string)
);

//remove all reminders

2 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/4/2023 in #questions
how to delete file in uploadthing
can anyone tell me how to delete file in upload things?
2 replies
TTCTheo's Typesafe Cult
Created by pradeep on 7/3/2023 in #questions
drizzle studio is not working
I am trying to open drizzle studio but it is giving me error can anyone tell my how to fix it? drizzle config:-
import type { Config } from "drizzle-kit";

export default {
schema: "./lib/db/schema.ts",
out: "./lib/db/migrations",
driver: "mysql2",

dbCredentials: { connectionString: process.env.DATABASE_URL as string },
breakpoints: true,
} satisfies Config;
import type { Config } from "drizzle-kit";

export default {
schema: "./lib/db/schema.ts",
out: "./lib/db/migrations",
driver: "mysql2",

dbCredentials: { connectionString: process.env.DATABASE_URL as string },
breakpoints: true,
} satisfies Config;
package.json "drizzle-kit": "^0.19.3", "drizzle-orm": "^0.27.0", error:- "mysql2" is not a valid driver. Available drivers: "pg", "mysql2", "better-sqlite", "libsql", "turso". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference
6 replies
TTCTheo's Typesafe Cult
Created by pradeep on 6/20/2023 in #questions
where clause in drizzle insert
await db
.insert(trackingQuestions)
.values({
questionNumber: questionNumber,
userId: session.user.id,
})
.where(
notExists(
db
.select()
.from(trackingQuestions)
.where(
and(
eq(trackingQuestions.questionNumber, questionNumber),
eq(trackingQuestions.userId, session.user.id)
)
)
)
);
await db
.insert(trackingQuestions)
.values({
questionNumber: questionNumber,
userId: session.user.id,
})
.where(
notExists(
db
.select()
.from(trackingQuestions)
.where(
and(
eq(trackingQuestions.questionNumber, questionNumber),
eq(trackingQuestions.userId, session.user.id)
)
)
)
);
can anyone tell why it's giving typescript error and how can i resolve it error: where clause doesn't exists i want to do this query with single query
11 replies
TTCTheo's Typesafe Cult
Created by pradeep on 6/15/2023 in #questions
Shadcn Ui library select is not working Properly in mobile?
hello guys, I am facing an issue with shadcn ui Select when I am clicking button it is also clicking the button which is right below it how can the issue can be resolved? (use toggle between device and choose any mobile)
3 replies
TTCTheo's Typesafe Cult
Created by pradeep on 6/12/2023 in #questions
useState is not working
can anyone tell me why in given below code is not working properly
const [localStorageTheme, setLocalStorageTheme] = useState(() => {
const lTheme = localStorage.getItem("localStorageTheme");
if (lTheme) {
return lTheme;
}
const isLight = window.matchMedia("(prefers-color-scheme: light)").matches;
console.log(isLight);
return isLight ? "light" : "dark";
});
const [localStorageTheme, setLocalStorageTheme] = useState(() => {
const lTheme = localStorage.getItem("localStorageTheme");
if (lTheme) {
return lTheme;
}
const isLight = window.matchMedia("(prefers-color-scheme: light)").matches;
console.log(isLight);
return isLight ? "light" : "dark";
});
let it return us "dark" but now i am trying to change dom by this value it is not working
{
<div
style={{
transitionTimingFunction: "steps(10)",
}}
className={`leading-none w-[660px] h-[100%] block overflow-hidden transition-transform ${
localStorageTheme === "dark" ? "translate-x-[-93%] " : "translate-x-0"
} duration-100`}
>
//code
</div>
}
{
<div
style={{
transitionTimingFunction: "steps(10)",
}}
className={`leading-none w-[660px] h-[100%] block overflow-hidden transition-transform ${
localStorageTheme === "dark" ? "translate-x-[-93%] " : "translate-x-0"
} duration-100`}
>
//code
</div>
}
in dom it is putting value of "translate-x-0" it should be "translate-x-[-93]"
49 replies
TTCTheo's Typesafe Cult
Created by pradeep on 6/9/2023 in #questions
EditorJs readOnly toggle is not working
hello guys, i am trying to make a editor in editorjs but when i am not writing anything and trying to toggle in editor it is giving me error of holder is undefine can you please help me resolve this issue? codesandbox link:-https://codesandbox.io/s/inspiring-frost-3v84mf?file=/src/App.js:559-848
3 replies
TTCTheo's Typesafe Cult
Created by pradeep on 6/8/2023 in #questions
how to remove query from Next js 13 app url without reloading?
how to remove query from next js 13 app url without reloading?
3 replies