84 Replies
Hi @ArDev. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, it is okay to modify the
main.wasp
file. This file is your app's definition file and it defines the app's central components. It is a list of declarations, each of which defines a part of your app. You can modify it to configure your app, define routes, pages, and more. However, it's important to note that currently, Wasp doesn't support dynamically changing the main.wasp
file or splitting it into multiple .wasp
files. These features are still in the works.
However, you should avoid modifying any of the .wasp
folder files as your changes will get overwritten the next time you start wasp start
. If you need to customize the build process, you can provide your own custom Dockerfile
in the project root (the same folder where main.wasp
lives). Wasp will use it when building your server.
Sources:
- main.wasp (https://wasp-lang.dev/docs/tutorial/project-structure#mainwasp)
- Discord support thread: Setting Environment-specific Values in main.wasp File > Answers (https://discord.com/channels/686873244791210014/1209467473389297684)
- Discord support thread: Modular .wasp files? > Original post (https://discord.com/channels/686873244791210014/1184362101494534165)
- Discord support thread: database url > Answers (https://discord.com/channels/686873244791210014/1205728717993672705)
- Discord support thread: Issue with deploying my wasp app to fly.io > Answers Part 2 (https://discord.com/channels/686873244791210014/1223671727943319584)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Yup, you should be modifying it! Check our tutorial for basics of Wasp https://wasp-lang.dev/docs/tutorial/create
1. Creating a New Project | Wasp
You'll need to have the latest version of Wasp installed locally to follow this tutorial. If you haven't installed it yet, check out the QuickStart guide!
import { search } from 'wasp/client/operations';
main.wasp - action search {
fn: import {search }"@src/server/main/actions.js",
entities: [User]
}#
is this a correct way to import?
@kapa.ai
Let me check the knowledge base for you. One moment! :books:
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
import { search } from 'wasp/client/operations';
main.wasp - action search {
fn: import {search }"@src/server/main/actions.js",
entities: [User]
}#
is this a correct way to import?
@kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
The import statement you've written in your
main.wasp
file seems to be incorrect. In Wasp, you define actions in the main.wasp
file and then provide the implementation in a separate JavaScript file. Here is the correct way to define an action in main.wasp
:
In the above code, search
is the name of the function that implements the action, which is located in the actions.js
file in the server
directory of the ext
folder.
Then, in your actions.js
file, you would define the search
function like this:
Please note that the context
argument contains useful information such as the authenticated user, Prisma client, and more.
Sources:
- Wasp Docs - Actions (https://wasp-lang.dev/docs/language/basic-elements#actions)
- Github Issue - Fix docs on calling queries and actions on the server (https://github.com/wasp-lang/wasp/issues/1909)
- Discord support thread - import actions into main.wasp (https://discord.com/channels/686873244791210014/1216119302244270181)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai how can i make it so i dont have to restart every time i make updates to my codebase?
so i dont have to do wasp start all the time?
Let me check the knowledge base for you. One moment! :books:
----------------------
Wasp has a built-in hot reloading feature. When you run
wasp start
, it launches the Wasp app in development mode and watches for any changes to .wasp
or files in src/
to automatically reflect in the browser. This means you don't have to restart the server every time you make changes to your codebase.
However, there have been some reports in the community about issues with hot reloading, particularly with UI file changes causing full app reloads. The Wasp team is aware of this and is actively working on a fix.
If you're experiencing issues with hot reloading, you might want to follow the progress on this issue on the Wasp GitHub page: https://github.com/wasp-lang/wasp/issues/1844
Sources:
- Wasp CLI Reference (https://wasp-lang.dev/docs/general/cli#project-commands)
- Discord support thread: Hot Reloading? (https://discord.com/channels/686873244791210014/1213985542480597022)
- Discord support thread: Possibility to disable wasp reload on UI file changes? (https://discord.com/channels/686873244791210014/1223304305206099969)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?However, there have been some reports in the community about issues with hot reloading, particularly with UI file changes causing full app reloads. The Wasp team is aware of this and is actively working on a fix.is this still the case though? this was fixed if my memory doesn't fail me kapa indexes discord threads? 😮
I believe the hot reloading issues are related strictly to WSL2 and having the project on Windows filesystem vs. the Linux filesystem.
@kapa.ai am I right?
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, you are correct. There is a known issue with WSL2 where file changes are not detected when your project is located on the Windows filesystem. This affects the hot reloading feature of Wasp (and other frameworks as well).
The recommended workaround for this issue is to move your project into the Linux filesystem root directory when using WSL2. This will enable Wasp to detect changes in your project and trigger hot reloads. You will also likely notice an increase in performance compared to the Windows filesystem root directory.
Here is a useful link for more information on this issue: https://github.com/microsoft/WSL/issues/4739
And here is a guide on how to do Wasp development on WSL: https://wasp-lang.dev/blog/2023/11/21/guide-windows-development-wasp-wsl
Sources:
- Github Issue (closed): File changes not detected by wasp start in WSL2 when using the Windows filesystem (https://github.com/wasp-lang/wasp/issues/603)
- Discord support thread: Hot Reloading? (https://discord.com/channels/686873244791210014/1213985542480597022)
- Docs > Quick Start > More details > Installation Part 2 (https://wasp-lang.dev/docs/quick-start#installation-1)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @miho, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
oh i see
@kapa.ai can i move my project into linux file system with just copy/paste?
Let me check the knowledge base for you. One moment! :books:
----------------------
Yes, you can move your project into the Linux filesystem by copying and pasting it. However, you need to ensure that you're doing this from within the WSL2 environment. Here's a general guide on how you can do it:
1. Open your WSL2 terminal.
2. Navigate to the directory where your project is currently located. For example, if your project is on your Windows desktop, you can access it in WSL2 with the command
cd /mnt/c/Users/YourUserName/Desktop
.
3. Copy your project directory to your desired location in the Linux filesystem. For example, to copy it to your home directory, you can use the command cp -r YourProjectName ~/
.
Please replace YourUserName
and YourProjectName
with your actual Windows username and your project's name.
Remember, after moving the project, you should use a code editor running in the WSL environment to make changes to your project files. If you're using VSCode, you can do this by installing the Remote - WSL (https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension.
Sources:
- Github Issue (closed): File changes not detected by wasp start in WSL2 when using the Windows filesystem (https://github.com/wasp-lang/wasp/issues/603)
- Discord support thread: Hot Reloading? (https://discord.com/channels/686873244791210014/1213985542480597022)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@kapa.ai how do to api calls?
Let me check the knowledge base for you. One moment! :books:
----------------------
In Wasp, you can make API calls using the
api
declaration. Here's a step-by-step guide on how to do it:
1. Declare the API in Wasp: You can do this in your main.wasp
file using the api
declaration. For example:
2. Define the API's NodeJS implementation: This should be a NodeJS function that takes three arguments: req
(Express Request object), res
(Express Response object), and context
(an additional context object injected into the API by Wasp). For example:
3. Use the API from the client: You can use the API from your client by importing the Axios wrapper from wasp/client/api
and invoking a call. For example:
Remember to ensure that CORS (Cross-Origin Resource Sharing) is enabled to use these APIs on the client side. You can do this by defining custom middleware for your APIs in the Wasp file.
Sources:
- Wasp Docs - Custom HTTP API Endpoints (https://wasp-lang.dev/docs/advanced/apis)
- Wasp Docs - Using the API from the Client (https://wasp-lang.dev/docs/advanced/apis#using-the-api-from-the-client)
- Wasp Docs - Defining the API's NodeJS Implementation (https://wasp-lang.dev/docs/advanced/apis#defining-the-apis-nodejs-implementation)
- Wasp Docs - Making Sure CORS Works (https://wasp-lang.dev/docs/advanced/apis#making-sure-cors-works)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @ArDev, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?