4z
TTCTheo's Typesafe Cult
•Created by Jotas on 11/2/2024 in #questions
Is tRPC in create-t3-app unsafe/public?
I think in your case it would make sense to have the delete user call be only available for admin role users or if the current session's user id is the same as the user id of the user being deleted.
5 replies
TTCTheo's Typesafe Cult
•Created by Jotas on 11/2/2024 in #questions
Is tRPC in create-t3-app unsafe/public?
There is this in my trpc.ts
/** Reusable middleware that enforces users are logged in before running the procedure. */
const enforceUserIsAuthed = t.middleware(({ ctx, next }) => {
if (!ctx.session || !ctx.session.user) {
throw new TRPCError({ code: 'UNAUTHORIZED' });
}
return next({
ctx: {
// infers the
session as non-nullable
session: { ...ctx.session, user: ctx.session.user },
},
});
});
/**
* Protected (authenticated) procedure
*
* If you want a query or mutation to ONLY be accessible to logged in users, use this. It verifies
* the session is valid and guarantees
ctx.session.user is not null.
*
* @see https://trpc.io/docs/procedures
*/
export const protectedProcedure = t.procedure.use(enforceUserIsAuthed);
Use it to protect your endpoints. You can check for roles from the context in the tRPC procedure and write a sort of 'audit log' by logging for example authorId: ctx.session?.user.id?.toString()
in your foo.router.ts
files.5 replies
TTCTheo's Typesafe Cult
•Created by 4z on 10/24/2024 in #questions
React UseState interface and eslint - am I doing this right?
To fill in the last missing code for this example I gave, this is the child component defined in the parent page
I hope my example code has been clear and you could understand it easily.
7 replies
TTCTheo's Typesafe Cult
•Created by Daniel K on 9/19/2023 in #questions
NEXT JS APP Hosting on AWS
If your react server components all use static rendering then it is possible https://nextjs.org/docs/pages/building-your-application/deploying/static-exports
13 replies
TTCTheo's Typesafe Cult
•Created by Lopen on 4/29/2023 in #questions
best way to protect my code and avoid piracy when selling it
I recommend improving the speed at which you iterate on new features and marketing. That way your business will beat all the possible copycats and make your customers happily choose you over your competition.
3 replies
TTCTheo's Typesafe Cult
•Created by Lopen on 4/29/2023 in #questions
best way to protect my code and avoid piracy when selling it
You know SaaS stands for Software as a service, right? A service does not need to provide source code to customers
3 replies
TTCTheo's Typesafe Cult
•Created by zendev on 4/19/2023 in #questions
File storage with T3
THen once you think its time to move to a cloud provider, just change the connection string because the API is the same
48 replies
TTCTheo's Typesafe Cult
•Created by zendev on 4/19/2023 in #questions
File storage with T3
you can self-host minio which has an s3 compatible API. As long as you mount a host directory in the container, you can host it anywhere with docker (for example a VPS)
48 replies
TTCTheo's Typesafe Cult
•Created by slavi_lns on 4/22/2023 in #questions
Amazon s3 alternative?
https://hub.docker.com/r/minio/minio/ . Remember to mount a host directory so that your files don't disappear when the container does
9 replies
TTCTheo's Typesafe Cult
•Created by Dale on 3/11/2023 in #questions
NextAuth and custom paths
maybe this will help https://next-auth.js.org/getting-started/client#specifying-a-callbackurl
6 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
but yes, I will go with the option that worked but does not validate the env variables
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
FYI I am not skipping env validation even tho I am using docker, what I'm doing is
set -a; source .env; set +a; docker-compose -f docker/docker-compose.dev.yml up
and the docker-compose.dev.yml file passes the env vars to the container which is built from Dockerfile.dev which mounts my code directory (so hot reload works) and runs next dev
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
there's this in the
next.config.mjs
file:
// @ts-check
/**
* Run
build or
dev with
SKIP_ENV_VALIDATION to skip env validation.
* This is especially useful for Docker builds.
*/
!process.env.SKIP_ENV_VALIDATION && (await import("./src/env.js/index.js"));
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
/**
* If you have the "experimental: { appDir: true }" setting enabled, then you
* must comment the below
i18n config out.
*
* @see https://github.com/vercel/next.js/issues/41980
*/
i18n: {
locales: ["en"],
defaultLocale: "en",
},
};
export default config;
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
wait... was this vscode changing imports wrong 🤔
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
docker-dev-1 | Running seed command
ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts ...
docker-dev-1 |
docker-dev-1 | 🌱 The seed command has been executed.
docker-dev-1 |
docker-dev-1 | > [email protected] dev /app
docker-dev-1 | > next dev
docker-dev-1 |
docker-dev-1 | node:fs:1583
docker-dev-1 | handleErrorFromBinding(ctx);
docker-dev-1 | ^
docker-dev-1 |
docker-dev-1 | Error: ENOTDIR: not a directory, stat '/app/src/env.js/index.js'
docker-dev-1 | at statSync (node:fs:1583:3)
docker-dev-1 | at tryStatSync (node:internal/modules/esm/resolve:183:13)
docker-dev-1 | at finalizeResolution (node:internal/modules/esm/resolve:323:17)
docker-dev-1 | at moduleResolve (node:internal/modules/esm/resolve:907:10)
docker-dev-1 | at defaultResolve (node:internal/modules/esm/resolve:1115:11)
docker-dev-1 | at nextResolve (node:internal/modules/esm/loader:163:28)
docker-dev-1 | at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
docker-dev-1 | at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
docker-dev-1 | at ESMLoader.import (node:internal/modules/esm/loader:525:22)
docker-dev-1 | at importModuleDynamically (node:internal/modules/esm/translators:110:35) {
docker-dev-1 | errno: -20,
docker-dev-1 | syscall: 'stat',
docker-dev-1 | code: 'ENOTDIR',
docker-dev-1 | path: '/app/src/env.js/index.js'
docker-dev-1 | }
docker-dev-1 | ELIFECYCLE Command failed with exit code 1.
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
ok, I will try
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
so this would be with the compiler option
{"module":"CommonJS"}
so that I can also import { PrismaClient } from '@prisma/client'
, right?47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
yea it would have been nice to validate them, but oh well
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
thanks @tropic
47 replies
TTCTheo's Typesafe Cult
•Created by 4z on 3/12/2023 in #questions
env vars in prisma db seed (prisma/seed.ts)
so the solution was to use
process.env
instead of trying to use src/env.mjs
47 replies