abcdef
abcdef
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
100+ components and like 30 pages
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
It's a big project though
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
32 gb ram should be enough?
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
And removed this shitty trpc library
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
I upgraded to next app dir
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
Guys I solved it
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
Didn't help
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
Ok I'll try that
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
Restarting my computer every 30 seconds wouldn't be an efficient use of time. I'd much rather avoid that.
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
This takes 30 sec to run
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
22 replies
TTCTheo's Typesafe Cult
Created by abcdef on 5/7/2023 in #questions
Prevent ts server from crashing every 5 mins
22 replies
TTCTheo's Typesafe Cult
Created by josh-dev627 on 5/5/2023 in #questions
How do you setup Shadcn with Create t3?
It literally says what the problem is
16 replies
TTCTheo's Typesafe Cult
Created by josh-dev627 on 5/5/2023 in #questions
How do you setup Shadcn with Create t3?
@josh-dev627 Have you tried reading the error message
16 replies
TTCTheo's Typesafe Cult
Created by albatroz on 5/4/2023 in #questions
Could someone help me with one to many relation in prisma?
Something like this should work
32 replies
TTCTheo's Typesafe Cult
Created by albatroz on 5/4/2023 in #questions
Could someone help me with one to many relation in prisma?
/* Middleware - middleware/validateApiKey.ts */
export const validateApiKey = (handler) => async (req, res) => {
const apiKey = req.headers["x-api-key"];

if (!apiKey) {
return res.status(401).json({ message: "Missing API key" });
}

const expectedApiKey = process.env.API_KEY;

if (apiKey !== expectedApiKey) {
return res.status(401).json({ message: "Invalid API key" });
}

return handler(req, res);
};



/* pages/api/route.ts */
import { validateApiKey } from "middleware/validateApiKey";

async function handler(req: NextApiRequest, res: NextApiResponse) {
// ...
}

export default validateApiKey(handler);
/* Middleware - middleware/validateApiKey.ts */
export const validateApiKey = (handler) => async (req, res) => {
const apiKey = req.headers["x-api-key"];

if (!apiKey) {
return res.status(401).json({ message: "Missing API key" });
}

const expectedApiKey = process.env.API_KEY;

if (apiKey !== expectedApiKey) {
return res.status(401).json({ message: "Invalid API key" });
}

return handler(req, res);
};



/* pages/api/route.ts */
import { validateApiKey } from "middleware/validateApiKey";

async function handler(req: NextApiRequest, res: NextApiResponse) {
// ...
}

export default validateApiKey(handler);
32 replies
TTCTheo's Typesafe Cult
Created by albatroz on 5/4/2023 in #questions
Could someone help me with one to many relation in prisma?
I'll send an example, hold on
32 replies
TTCTheo's Typesafe Cult
Created by albatroz on 5/4/2023 in #questions
Could someone help me with one to many relation in prisma?
You can use a middleware
32 replies
TTCTheo's Typesafe Cult
Created by albatroz on 5/4/2023 in #questions
Could someone help me with one to many relation in prisma?
You want to limit access to the endpoint with an api key?
32 replies
TTCTheo's Typesafe Cult
Created by albatroz on 5/4/2023 in #questions
Could someone help me with one to many relation in prisma?
const savedReportDB = await prisma.reportDatabse.create({
data: {
userId,
generatedFor: yesterday,
savedWeight: {
connect: savedWeight.map((weight) => ({ weightId: weight.weightId })),
},
savedLiter: {
connect: savedLiter.map((liter) => ({ literId: liter.literId })),
},
savedPieceCounting: {
connect: savedPieceCounting.map((piece) => ({ pieceId: piece.pieceId })),
},
savedGrades: {
connect: savedGrades.map((grade) => ({ gradeId: grade.gradeId })),
},
AlertDatabase: {
connect: AlertDatabase.map((alert) => ({ alertId: alert.alertId })),
},
},
});
const savedReportDB = await prisma.reportDatabse.create({
data: {
userId,
generatedFor: yesterday,
savedWeight: {
connect: savedWeight.map((weight) => ({ weightId: weight.weightId })),
},
savedLiter: {
connect: savedLiter.map((liter) => ({ literId: liter.literId })),
},
savedPieceCounting: {
connect: savedPieceCounting.map((piece) => ({ pieceId: piece.pieceId })),
},
savedGrades: {
connect: savedGrades.map((grade) => ({ gradeId: grade.gradeId })),
},
AlertDatabase: {
connect: AlertDatabase.map((alert) => ({ alertId: alert.alertId })),
},
},
});
^^ If they're all arrays
32 replies