CamBlackwood
CamBlackwood
Explore posts from servers
WWasp
Created by CamBlackwood on 1/13/2025 in #đŸ™‹questions
Is this an invalid action? Getting a 500 when calling, no error logs
I'm trying to do a simple update call but getting a 500 from prisma, with this message
Error:
Invalid `prisma.creators.update()` invocation:

{
+ data: CreatorsUpdateInput | CreatorsUncheckedUpdateInput,
+ where: {
+ id?: Int,
+ userId?: Int
+ }
}

Argument data is missing.
Argument where is missing.

Note: Lines with + are required
Error:
Invalid `prisma.creators.update()` invocation:

{
+ data: CreatorsUpdateInput | CreatorsUncheckedUpdateInput,
+ where: {
+ id?: Int,
+ userId?: Int
+ }
}

Argument data is missing.
Argument where is missing.

Note: Lines with + are required
This is my action:
export const modifyVerificationStatusCreator = async ({ verify, idToUpdate, userIdToUpdate }, context) => {
if (!verify || !idToUpdate) {
throw new Error('Both `verify` and `idToUpdate` are required.');
}
console.log(verify, idToUpdate);
if (!context.user) {
throw new HttpError(401);
}
return await context.entities.Creators.update({
where: {
id: idToUpdate,
userId: userIdToUpdate,
},
data: {
verified: verify,
},
});
};
export const modifyVerificationStatusCreator = async ({ verify, idToUpdate, userIdToUpdate }, context) => {
if (!verify || !idToUpdate) {
throw new Error('Both `verify` and `idToUpdate` are required.');
}
console.log(verify, idToUpdate);
if (!context.user) {
throw new HttpError(401);
}
return await context.entities.Creators.update({
where: {
id: idToUpdate,
userId: userIdToUpdate,
},
data: {
verified: verify,
},
});
};
8 replies
WWasp
Created by CamBlackwood on 1/10/2025 in #đŸ™‹questions
UseQueries Support unavailable - best way around it?
I'm attempting to use the usequeries hook from tanstack query v4 - https://tanstack.com/query/v4/docs/framework/react/reference/useQueries as part of the wasp operations (like useQuery), but it's not be recognised by wasp. If it's not supported it's not a problem, but what can I use as an alternative when I want to batch a few requests together?
12 replies
WWasp
Created by CamBlackwood on 1/3/2025 in #đŸ™‹questions
Relation returned on findFirst but not findMany?
I am looking to make a query to return a batch of results rather than just one, but "profile" is not included in the findMany, only in the findFirst Returns profile -
export const getCreatorById: GetCreatorById<any, any> = async ({ creatorId }, context) => {
if (!context.user) {
throw new HttpError(401);
}
return context.entities.Creators.findFirst({
orderBy: { id: 'asc' },
where: {
AND: [
{
userId: +creatorId,
},
],
},
include: {
profile: true,
stats: true,
},
});
};
export const getCreatorById: GetCreatorById<any, any> = async ({ creatorId }, context) => {
if (!context.user) {
throw new HttpError(401);
}
return context.entities.Creators.findFirst({
orderBy: { id: 'asc' },
where: {
AND: [
{
userId: +creatorId,
},
],
},
include: {
profile: true,
stats: true,
},
});
};
Does not return profile:
export const getCreators: GetCreators<any, any> = async (args, context) => {
if (!context.user) {
throw new HttpError(401);
}
return context.entities.Creators.findMany({
orderBy: { id: 'asc' },
include: {
stats: true,
youtubeStats: true,
profile: true
},
});
};
export const getCreators: GetCreators<any, any> = async (args, context) => {
if (!context.user) {
throw new HttpError(401);
}
return context.entities.Creators.findMany({
orderBy: { id: 'asc' },
include: {
stats: true,
youtubeStats: true,
profile: true
},
});
};
Am I missing aything @kapa.ai ?
14 replies
WWasp
Created by CamBlackwood on 12/13/2024 in #đŸ™‹questions
Can't access auth methods?
I am trying to use import { getRedirectUriForOneTimeCode, tokenStore } from "wasp/server/auth"; as defined in this gist - https://gist.github.com/infomiho/3c63de7d53aba59d6293bcb59501a029 However, they aren't recognised by Wasp - I am running 0.14.2
9 replies
WWasp
Created by CamBlackwood on 12/10/2024 in #đŸ™‹questions
Best way of handling custom oauth call Frontend to Backend?
I am looking to allow users to connect their TikTok account. My current plan is to call a webhook from the frontend, where I would process the request and feed the response back, but what's the best way of doing it? It is a standard OAuth call.
29 replies
WWasp
Created by CamBlackwood on 12/9/2024 in #đŸ™‹questions
Safest way to add a new required property to a schema model in a production project?
I have an existing project that has a number of existing users. On the User schema, I want to add a new property (a list of ints). This will be mandatory (although initiated as an empty list). What is the best way of dealing with this safely to ensure my prod database is not at risk?
9 replies
WWasp
Created by CamBlackwood on 12/4/2024 in #đŸ™‹questions
Optimial way of handling two types of users (authorisation)
I have two types of users, who can all do some operations, but each have their own unique set if pages/operations they can complete. For the operations, I am adding a simple check against their property, and I am redirecting off unauthorised pages manually. What I'm primarily asking is that if there's a simple way of blocking access to all routes matching a certain pattern unless a user matches certain requirements? Eg users marked as "creator" should only be able to access routes that are under "/creator/"
8 replies
WWasp
Created by CamBlackwood on 11/30/2024 in #đŸ™‹questions
Job paths not resolving
I've been defining jobs the normal way (at least in wasp 0.14), and the compiler will not resolve the paths, even after manually rewriting them several times. job updateYTStats { executor: PgBoss, perform: { fn: import {updateStaleYouTubeStats} from "@src/server/workers/updateStaleYoutubeStats", }, schedule: { cron: "* * * * *" }, entities: [UnverifiedCreator, UnverifiedCreatorYouTubeStats] } the function exists at the root of the server/workers folder. Is there anything obvious I am missing @kapa.ai ?
8 replies
WWasp
Created by CamBlackwood on 11/30/2024 in #đŸ™‹questions
Is there any issue with > 1 job running simultaneously when the server is deployed on one machine?
I'm running a few jobs on invervals that might overlap. If I'm deployed on one machine, could that cause any issues?
12 replies
WWasp
Created by CamBlackwood on 11/20/2024 in #đŸ™‹questions
Cron job not running in production but running locally
I am attempting to run this job but it is not appearing to run in the logs, whereas it runs locally (every 5 minutes). The first line is a console log so regardless of the result, it should log something
job updateStaleTikTokStats {
executor: PgBoss,
perform: {
fn: import {updateStaleTikTokStats} from "@src/server/workers/updateStaleTikTokStats"
},
schedule: {
cron: "*/5 * * * *"
},
entities: [UnverifiedCreator, UnverifiedCreatorTikTokStats]
}
job updateStaleTikTokStats {
executor: PgBoss,
perform: {
fn: import {updateStaleTikTokStats} from "@src/server/workers/updateStaleTikTokStats"
},
schedule: {
cron: "*/5 * * * *"
},
entities: [UnverifiedCreator, UnverifiedCreatorTikTokStats]
}
18 replies
WWasp
Created by CamBlackwood on 10/24/2024 in #đŸ™‹questions
Expected Behaviour when running flyctl certs list -a <client app name>
@kapa.ai I'm fixing an issue where my site does not load at all when prefixing with www. It loads fine without it. I realised I was missing a CNAME record with www, so I've added one in my DNS settings, but when running flyctl certs list -a <client app name> I only get the domain without the www back. Is that expected? I have updated the DNS but it has only been a few minutes.
5 replies
WWasp
Created by CamBlackwood on 10/17/2024 in #đŸ™‹questions
Best setup for cascading?
As part of my app, I have advanced stats for user profiles contained in a seperate table with a foriegn key relation. When deleting a user profile, I need to also delete the row in the advanced stats table (both for practical reasons, and because the process fails if I don't). What's the best way of doing that - I assume it's using onDelete in the schema file?
6 replies
WWasp
Created by CamBlackwood on 10/12/2024 in #đŸ™‹questions
Job Hanging/Not Working when processing a large loop
I'm running a job on my database that current involves iterating over 800 elements and making an api call on each one, but it never gets past the first iteration, and nothing logs out. Is there anything it looks like I'm doing wrong? I've cut out some parts of the code to save on message length restrictions (mainly irrelevant variables)
export const updatePlatformStats = async (_args, context) => {
const unverifiedUsers = await context.entities.UnverifiedUser.findMany({
where: {
platformUsername: {
not: null,
},
},
});
for (let user of unverifiedUsers) {
const fullResponse = await fetch(
`https://api.someapi.com/v1/profile-videos?handle=${user.platformUsername}&amount=10
);

if (!fullResponse.ok) {
continue;
}

const videos = await fullResponse.json();
const formattedVideos = Array.from(videos).map((video: any) => {
return {
hashtags: video.challenges.map((challenge) => challenge.title),
stats: video.stats || null,
description: video.desc,
createdAt: video.createTime || null,
};
});
try {
const res = await context.entities.UnverifiedUserStats.upsert({
where: {
userId: user.id,
},
update: {
totalEngagementRate: parsedEngagementRate,
averageViews,
labelsUsed: [],
hashtagsUsed,
lastVideoDate,
},
create: {
totalEngagementRate: parsedEngagementRate,
averageViews,
labelsUsed: [],
hashtagsUsed,
lastVideoDate,
user: { connect: { id: user.id } },
},
});
} catch (error) {
console.error('Database upsert failed:', error);
}
}
};
export const updatePlatformStats = async (_args, context) => {
const unverifiedUsers = await context.entities.UnverifiedUser.findMany({
where: {
platformUsername: {
not: null,
},
},
});
for (let user of unverifiedUsers) {
const fullResponse = await fetch(
`https://api.someapi.com/v1/profile-videos?handle=${user.platformUsername}&amount=10
);

if (!fullResponse.ok) {
continue;
}

const videos = await fullResponse.json();
const formattedVideos = Array.from(videos).map((video: any) => {
return {
hashtags: video.challenges.map((challenge) => challenge.title),
stats: video.stats || null,
description: video.desc,
createdAt: video.createTime || null,
};
});
try {
const res = await context.entities.UnverifiedUserStats.upsert({
where: {
userId: user.id,
},
update: {
totalEngagementRate: parsedEngagementRate,
averageViews,
labelsUsed: [],
hashtagsUsed,
lastVideoDate,
},
create: {
totalEngagementRate: parsedEngagementRate,
averageViews,
labelsUsed: [],
hashtagsUsed,
lastVideoDate,
user: { connect: { id: user.id } },
},
});
} catch (error) {
console.error('Database upsert failed:', error);
}
}
};
24 replies
WWasp
Created by CamBlackwood on 10/9/2024 in #đŸ™‹questions
Is it good practice to call an action in a job in wasp?
I have several processes in my app that normally run on cron jobs, but sometimes I want to click a button to run them manually via an admin dashboard (both for testing and for their actual functionality). Is it good practice to just create an action, and call it both from the front end and in a job?
20 replies
WWasp
Created by CamBlackwood on 10/7/2024 in #đŸ™‹questions
Best way of adding a 404 page?
What's the optimum way of adding a 404 page to my wasp app - should I take the react router standard approach of a wildcard match as the last route listed?
7 replies
WWasp
Created by CamBlackwood on 10/4/2024 in #đŸ™‹questions
Making sure www.<mysite>.com redirects to https://<mysite>.com?
@kapa.ai
This isn't really a wasp question as such (although it is a wasp app). I noticed my website only works with https:// in front and the www doesn't redirect after I deployed it on fly.io. What should I check to repair this?
6 replies
WWasp
Created by CamBlackwood on 10/1/2024 in #đŸ™‹questions
Deploying Client Side Env Variables/Incorrect Useage?
I had client side env variables successfully running in production for a few days before they seemingly "turned off" (are undefined) - I didn't change anything (that I know of) This is how I use the variables
function isRunningLocally() {
return window.location.hostname === 'localhost';
}
if (!isRunningLocally()) {
// this isn't running
posthog.init(import.meta.env.REACT_APP_PUBLIC_POSTHOG_KEY!, {
api_host: import.meta.env.REACT_APP_PUBLIC_POSTHOG_HOST,
person_profiles: 'always',
});
}
function isRunningLocally() {
return window.location.hostname === 'localhost';
}
if (!isRunningLocally()) {
// this isn't running
posthog.init(import.meta.env.REACT_APP_PUBLIC_POSTHOG_KEY!, {
api_host: import.meta.env.REACT_APP_PUBLIC_POSTHOG_HOST,
person_profiles: 'always',
});
}
I set them via the REACT_APP_ANOTHER_VAR=somevalue wasp deploy fly deploy syntax as mentioned in the docs here - https://wasp-lang.dev/docs/advanced/deployment/cli#environment-variables-1 Is there anything I might have done wrong here?
21 replies
WWasp
Created by CamBlackwood on 9/29/2024 in #đŸ™‹questions
Is there a way for me to run a SQL query on my local database?
I've had some issues with my local db due to a manual error, so I can't complete a migration. I know what the issue is (I need to delete some duplicate rows), but is it possible for me to run SQL on my local db?
8 replies
WWasp
Created by CamBlackwood on 9/24/2024 in #đŸ™‹questions
Cron jobs running locally?
This is almost certainly a really stupid question, but I assume if the server is running locally, cron jobs will still fire and therefore update my database (when updating it in the job, of course)
13 replies
WWasp
Created by CamBlackwood on 9/23/2024 in #đŸ™‹questions
Set up client environment variables and deployed, but not defined on prod?
I've integrated Posthog into my wasp application, but whilst it works locally with my environment variables, it does not work when deployed. As mentioned in the docs, I am using the correct syntax - eg. import.meta.env.REACT_APP_PUBLIC_POSTHOG_HOST, I have also made sure to deploy these new secrets to prod, and when requesting them via fly secrets list -a <app name>, they come back. However, when attempting to initalise posthog on prod, it throws an error saying the API key is undefined
14 replies