Kynetix
WWasp-lang
•Created by Kynetix on 10/28/2024 in #đŸ™‹questions
Display app version in UI
In my OpenSaaS, I added 'version:0.1.1' to the package.json file in /app/, and I want to display it on the UI. How do I accomplish that?
I added the following to operations.ts
export const getAppVersion = () => {
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const packageJson = JSON.parse(
readFileSync(path.join(dirname, '../package.json'), 'utf8')
);
return packageJson.version;
}
updated main.wasp with
query getAppVersion {
fn: import { getAppVersion } from "@src/docfolio/operations",
}
and in the UI
import { ggetAppVersion } from 'wasp/client/operations';
...
const { data: version } = useQuery(getAppVersion);
console.log(version);
but it returns '0.0.0'.
Further research indicates that it's looking at the package.json in .wasp/out/server/. Is that where I should set it?
14 replies
WWasp-lang
•Created by Kynetix on 10/23/2024 in #đŸ™‹questions
File is not defined
My OpenSaas application has a file upload feature where you upload a file and send it to the nodejs backend (as a File object) to read the content, etc. It works fine on my macbook (wasp start), but once published to Railway, when I upload the file, I get the "ReferenceError: File is not defined" error. The line causing the error is "const reconstructedFile = new File([fileBase64], metadata.fileName, { type: metadata.fileType })"
I know that nodeJS doesn't understand the File object, but why does it work when I run it locally (via wasp start), but not on the Railway server? Aren't they both nodeJS environments?
23 replies
WWasp-lang
•Created by Kynetix on 10/18/2024 in #đŸ™‹questions
PayloadTooLargeError
I'm creating an OpenSaas document application. When the user uploads a file, it sends the file to the operations.ts backend for processing. However, I'm getting a "PayloadTooLargeError: request entity too large" error, even when trying to upload an 80kb file. I created a serverSetup.js file and added
"export const serverSetup = () => {
app.use(express.json({ limit: '50mb' }));
app.use(express.urlencoded({ limit: '50mb' , extended: true }));
}"
but I still get the error. How can I fix this? Any help would be appreciated.
This is the upload function in the backend:
export const uploadDocument = async (args: {
fileBase64: string;
metadata: { fileName: string; fileType: string; fileSize: number; };
user_id: string;
labels: string;
}, context: any) => {
//... etc
27 replies
WWasp-lang
•Created by Kynetix on 10/16/2024 in #đŸ™‹questions
process is not defined
I'm building a chatbot SAAS using OpenSAAS. I created the app files (.tsx and operations.ts) in its own folder, just like the demo app. I also stored some API keys in .env.server, and I'm trying to access them in operations.ts via process.env, but when I run it, it always errors saying "process is not defined" (dev console points to config.ts), but the demo app (which also uses process.env) works fine.
Can anyone help? Is there a step I'm missing?
Here's a snippet of code trying to access OpenAI's key
function setupOpenAI() {
if (!import.meta.env.REACT_APP_OPENAI_API_KEY) {
return new HttpError(500, 'OpenAI API key is not set');
}
return new OpenAI({ apiKey: import.meta.env.REACT_APP_OPENAI_API_KEY });
}
14 replies