ZiiM
ZiiM
TTCTheo's Typesafe Cult
Created by ZiiM on 5/29/2024 in #questions
Error in Nvim with TS related LSPs.
No description
3 replies
TTCTheo's Typesafe Cult
Created by ZiiM on 10/10/2023 in #questions
Proper way to handle api routes with Go
Hey, I'm just wondering what the correct way to handle API routes with Go is. Currently, I have a route, for example, /post, and then I am switching over the request method to handle it. So, if you send a GET request to /post, it retrieves all the posts. If you send a POST request to /post, it creates a new post. Is this the correct way, or is having a separate route for each method a better approach?
3 replies
TTCTheo's Typesafe Cult
Created by ZiiM on 5/6/2023 in #questions
"SyntaxError: Cannot use import statement outside a module" when attempting to build a turborepo app
I have a turbo repo that has a websocket app. I have a package for my redis client so it can be used in all my apps. However when I try to start my websocket app in production I get
F:\Dev\radiance\packages\redis\index.ts:1
import Redis, { type RedisOptions } from "ioredis";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (F:\Dev\radiance\apps\websocket\dist\wsServer.js:4:17)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
F:\Dev\radiance\packages\redis\index.ts:1
import Redis, { type RedisOptions } from "ioredis";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (F:\Dev\radiance\apps\websocket\dist\wsServer.js:4:17)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
I am believe its not transpiling the internal pacakges correctly but unsure how to solve. Linked the repo below. https://github.com/ZiiMs/Radiance Thanks for the help.
5 replies
TTCTheo's Typesafe Cult
Created by ZiiM on 12/21/2022 in #questions
Stop Pnpm moving packages installed by different package manager to .ignored
So basically any time I run pnpm add or install commands. It will move packages installed by another package manager to .ignored, I want it to stop moving them.
4 replies
TTCTheo's Typesafe Cult
Created by ZiiM on 11/30/2022 in #questions
NextJS body exceed limit when content sent in body is under limit.
I am sending a photo through TRPC that is then being uploaded to a server. Everything is working except sometimes it exceeds the body limit of nextjs api calls even tho I know the image is less than the limit.
const size = image.size / 1024;
console.log(size);
if (size >= 4096) {
console.log("Error, image to large");
return;
}
const foundText = await image.arrayBuffer();
console.log("NewSize", foundText.byteLength / 1024);
const uint = new Uint8Array(foundText);
console.log("BlogStringw", uint.length / 1024); // Shows the correct size, if I upload a 3mb file it shows its 3000kb.

upload(uint, false, image.type);
setImage(null);
setIsDragging(false);

const size = image.size / 1024;
console.log(size);
if (size >= 4096) {
console.log("Error, image to large");
return;
}
const foundText = await image.arrayBuffer();
console.log("NewSize", foundText.byteLength / 1024);
const uint = new Uint8Array(foundText);
console.log("BlogStringw", uint.length / 1024); // Shows the correct size, if I upload a 3mb file it shows its 3000kb.

upload(uint, false, image.type);
setImage(null);
setIsDragging(false);

export const config = { // Config for bodyparser it is working
api: {
bodyParser: {
sizeLimit: "8mb", // Set desired value here
},
},
};
export const config = { // Config for bodyparser it is working
api: {
bodyParser: {
sizeLimit: "8mb", // Set desired value here
},
},
};
Errors: POST http://localhost:3000/api/trpc/images.create?batch=1 413 (Body exceeded 8mb limit) which obviously errors TRPC.
5 replies
TTCTheo's Typesafe Cult
Created by ZiiM on 10/24/2022 in #questions
Best way to handle who is online.
I have a basic T3 app that is a chat app It has the ability to create separate rooms. I am using web sockets and handle messages, etc. and I can track when someone connects, I just am unsure of how I should handle how the person connects. My current ideas are: 1. Just take the id and store it into a object on the server then just fetch it through trpc. The problem I can see with that is the object could become quite large if you have a large number of users. 2. Store who is online at the time in a DB, it would make it so I can easily query through the data without worrying about handling large objects. Only problem is it would be tons of query's to the DB.
3 replies
TTCTheo's Typesafe Cult
Created by ZiiM on 10/17/2022 in #questions
Any good librarys for parallaxs
Looking for a good library to make parallax's easy.
3 replies