fustuk.
fustuk.
WWasp-lang
Created by fustuk. on 10/10/2024 in #đŸ™‹questions
Wasp Railway Migrations
No description
8 replies
WWasp-lang
Created by fustuk. on 9/26/2024 in #đŸ™‹questions
Custom session token
Hey, I somehow need to issue a new token instead of using google/disc/email auth, is there a way to do that somehow? I couldnt find anything in the docs for some reason
export const getTokenByClerkId = async (req: any, res: any, context: any) => {
try {
const clerkId = req?.query?.clerkId || '';
const user = await context.entities.User.findUnique({
where: { clerkUserId: clerkId },
});

if (!user) {
throw new Error('User not found');
}
// Sent session token for get /me info
res.status(200).json({ message: user });
} catch (error) {
res.status(401).json({ message: error });
}
}
export const getTokenByClerkId = async (req: any, res: any, context: any) => {
try {
const clerkId = req?.query?.clerkId || '';
const user = await context.entities.User.findUnique({
where: { clerkUserId: clerkId },
});

if (!user) {
throw new Error('User not found');
}
// Sent session token for get /me info
res.status(200).json({ message: user });
} catch (error) {
res.status(401).json({ message: error });
}
}
22 replies
WWasp-lang
Created by fustuk. on 9/16/2024 in #đŸ™‹questions
Backend public?
Is there a way that I can make my api accessible from localhost while its on prod? The current frontend and api are hosted already and working, but I want to also access it from localhost(for now) and other domains later on.
57 replies
WWasp-lang
Created by fustuk. on 9/11/2024 in #đŸ™‹questions
Zero length key (google auth) ??
No description
7 replies
WWasp-lang
Created by fustuk. on 9/9/2024 in #đŸ™‹questions
Are there any future plans of implementing something like Clerk's organizations?
8 replies
WWasp-lang
Created by fustuk. on 9/2/2024 in #đŸ™‹questions
SendGrid 403 Error
I have updated this part in main.wasp
emailSender: {
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "Mailgun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
provider: SendGrid,
defaultFrom: {}
emailSender: {
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "Mailgun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
provider: SendGrid,
defaultFrom: {}
I didnt do anything else, I have a custom endpoint that sends emails properly, but when I try to register a user via email I get 403
[ Server!] Failed to send email ResponseError: Forbidden
[ Server!] at /home/kaloyan/projects/podcast-FE/app/node_modules/@sendgrid/client/src/classes/client.js:146:29
[ Server!] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[ Server!] code: 403,
[ Server!] response: {
[ Server!] headers: {
[ Server!] server: 'nginx',
[ Server!] date: 'Mon, 02 Sep 2024 10:41:16 GMT',
[ Server!] 'content-type': 'application/json',
[ Server!] 'content-length': '281',
[ Server!] connection: 'keep-alive',
[ Server!] 'access-control-allow-origin': 'https://sendgrid.api-docs.io',
[ Server!] 'access-control-allow-methods': 'POST',
[ Server!] 'access-control-allow-headers': 'Authorization, Content-Type, On-behalf-of, x-sg-elas-acl',
[ Server!] 'access-control-max-age': '600',
[ Server!] 'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/API/cors.html',
[ Server!] 'strict-transport-security': 'max-age=600; includeSubDomains'
[ Server!] },
[ Server!] body: { errors: [Array] }
[ Server!] }
[ Server!] }
[ Server!] Failed to send email ResponseError: Forbidden
[ Server!] at /home/kaloyan/projects/podcast-FE/app/node_modules/@sendgrid/client/src/classes/client.js:146:29
[ Server!] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[ Server!] code: 403,
[ Server!] response: {
[ Server!] headers: {
[ Server!] server: 'nginx',
[ Server!] date: 'Mon, 02 Sep 2024 10:41:16 GMT',
[ Server!] 'content-type': 'application/json',
[ Server!] 'content-length': '281',
[ Server!] connection: 'keep-alive',
[ Server!] 'access-control-allow-origin': 'https://sendgrid.api-docs.io',
[ Server!] 'access-control-allow-methods': 'POST',
[ Server!] 'access-control-allow-headers': 'Authorization, Content-Type, On-behalf-of, x-sg-elas-acl',
[ Server!] 'access-control-max-age': '600',
[ Server!] 'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/API/cors.html',
[ Server!] 'strict-transport-security': 'max-age=600; includeSubDomains'
[ Server!] },
[ Server!] body: { errors: [Array] }
[ Server!] }
[ Server!] }
27 replies
WWasp-lang
Created by fustuk. on 8/28/2024 in #đŸ™‹questions
Serve /public files in prod (build)
Hello, I have a weird scenario in which I download a file on my API, save it in /public so the frontend can access it, and then I spin remotion to render the video in the background. Issue is I keep getting errors saying Error: ENOENT: no such file or directory, open '/app/public/0b985bfc-3d43-49d6-8d4c-7cc4bff1e24e.mp4' Some of the code used for this:
const videoPath = path.join(process.cwd(), '..','..','..', 'public', `${filename}.mp4`);

const x = await downloadFromPresignedUrl(s3, videoPath)
.then(() => console.log('Download completed'))
.catch(err => console.error('Download failed', err));
const compositionId = 'CaptionedVideo';
const compPath = path.join(process.cwd(),'..','..','..', "src/demo-ai-app/index.ts")

const bundleLocation = await bundle({
// entryPoint: path.resolve('src/demo-ai-app/index.ts'),
entryPoint: compPath,
webpackOverride: (config) => config,
});
const allWords = output.segments.flatMap((segment: { words: any; }) => segment.words);
const inputProps = {
videoSrc: videoPath,
src: `/public/${filename}.mp4`,
s3: s3,
words: allWords
};
const composition = await selectComposition({
serveUrl: bundleLocation,
id: compositionId,
inputProps,
});
const captioned = path.join(process.cwd(), '..','..','..', 'public',`${filename}_captioned.mp4`);
await renderMedia({
composition,
serveUrl: bundleLocation,
codec: 'h264',
outputLocation: `${captioned}`,
inputProps,
});
const videoPath = path.join(process.cwd(), '..','..','..', 'public', `${filename}.mp4`);

const x = await downloadFromPresignedUrl(s3, videoPath)
.then(() => console.log('Download completed'))
.catch(err => console.error('Download failed', err));
const compositionId = 'CaptionedVideo';
const compPath = path.join(process.cwd(),'..','..','..', "src/demo-ai-app/index.ts")

const bundleLocation = await bundle({
// entryPoint: path.resolve('src/demo-ai-app/index.ts'),
entryPoint: compPath,
webpackOverride: (config) => config,
});
const allWords = output.segments.flatMap((segment: { words: any; }) => segment.words);
const inputProps = {
videoSrc: videoPath,
src: `/public/${filename}.mp4`,
s3: s3,
words: allWords
};
const composition = await selectComposition({
serveUrl: bundleLocation,
id: compositionId,
inputProps,
});
const captioned = path.join(process.cwd(), '..','..','..', 'public',`${filename}_captioned.mp4`);
await renderMedia({
composition,
serveUrl: bundleLocation,
codec: 'h264',
outputLocation: `${captioned}`,
inputProps,
});
48 replies
WWasp-lang
Created by fustuk. on 8/28/2024 in #đŸ™‹questions
Dark theme by default?
Hey, I was wondering how to make 'dark' as default theme
export default function useColorMode() {
const [colorMode, setColorMode] = useLocalStorage('color-theme', 'light');

useEffect(() => {
const className = 'dark';
const bodyClass = window.document.body.classList;

colorMode === 'dark'
? bodyClass.add(className)
: bodyClass.remove(className);
}, [colorMode]);

return [colorMode, setColorMode];
export default function useColorMode() {
const [colorMode, setColorMode] = useLocalStorage('color-theme', 'light');

useEffect(() => {
const className = 'dark';
const bodyClass = window.document.body.classList;

colorMode === 'dark'
? bodyClass.add(className)
: bodyClass.remove(className);
}, [colorMode]);

return [colorMode, setColorMode];
I thought that this is is where its getting set initially but after changing useLocalStorage('color-theme', 'dark'); it is still the same
6 replies
WWasp-lang
Created by fustuk. on 8/21/2024 in #đŸ™‹questions
CORS on custom API endpoint
This is what I have in api.ts file import { MiddlewareConfigFn } from "wasp/server"; import { FooBar } from "wasp/server/api"; // This type is generated by Wasp based on the api declaration above. export const apiMiddleware: MiddlewareConfigFn = (config) => { return config; }; export const fooBar: FooBar = (req, res, context) => { res.set("Access-Control-Allow-Origin", ""); // Example of modifying headers to override Wasp default CORS middleware. res.json({ msg: Hello, ${context.user ? "registered user" : "stranger"}! }); }; // export const fooBar = (req: any, res: { // set: (arg0: string, arg1: string) => void; // json: (arg0: { msg: string; }) => void; // }, context: { user: any; }) => { // console.log("Hello from fooBar!"); // console.log("User:", context.user); // res.set("Access-Control-Allow-Origin", ""); // Example of modifying headers to override Wasp default CORS middleware. // res.json({ msg: Hello, ${context.user ? "registered user" : "stranger"}! }); // }; And in main.wasp api fooBar { fn: import { fooBar } from "@src/api", httpRoute: (GET, "/foo/bar"), auth: true, middlewareConfigFn: import { apiMiddleware } from "@src/api" } I get CORS when hitting it for some reason, as you can see I tried using it with auth,without auth with res.set("Access-Control-Allow-Origin", "*");
nothing seems to fix it, any ideas?
17 replies
WWasp-lang
Created by fustuk. on 8/19/2024 in #đŸ™‹questions
User Subsctiption plan change?
I couldnt find anything in the docs regarding this, how can a user change or cancel his subscription plan ? Is this integrated or do I have to build it myself
4 replies