9 Replies
Hi @senorioano. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Wasp provides a streamlined way to build the backend for your SaaS application. It uses Node.js and Prisma under the hood to handle server queries and actions. Here are the steps to deploy your backend:
1. Generate deployable code by running the command
wasp build
. This generates deployable code for the whole app in the .wasp/build/
directory.
2. Deploy the API server (backend). There's a Dockerfile that defines an image for building the server in the .wasp/build
directory. Deploy this Docker image to a hosting provider and ensure the required environment variables on the provider are correctly set up.
The environment variables your server will be looking for are:
- DATABASE_URL
: The URL of the PostgreSQL database you want your app to use.
- WASP_WEB_CLIENT_URL
: The URL where you plan to deploy your frontend app is running.
- WASP_SERVER_URL
: The URL where the server is running.
- JWT_SECRET
: You only need this environment variable if you're using Wasp's auth
features.
- PORT
: The server's HTTP port number.
Remember, Wasp supports multiple database backends, but for production, you'll need to switch to PostgreSQL. Wasp needs access to your database for commands such as wasp start
or wasp db migrate-dev
and expects to find a connection string in the DATABASE_URL
environment variable.
For more detailed instructions, you can refer to the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-a-wasp-app).
Sources:
- Wasp Documentation: Deploying a Wasp App (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-a-wasp-app)
- Wasp Documentation: Databases (https://wasp-lang.dev/docs/data-model/backends)
- Wasp Documentation: Environment Variables (https://wasp-lang.dev/docs/advanced/deployment/manually#environment-variables)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @senorioano, 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?Nah I was talking about the development of the backend of my app, the server, not deployment. Should I use next.js api routing? I am using opensaas btw @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
For the development of your backend, Wasp uses Node.js and Prisma. It provides a way to define your data model and queries/actions (equivalent to REST API endpoints) in a declarative manner.
In the context of OpenSaaS, which is a template for Wasp, you would be defining your backend logic primarily in the
server/
directory. This includes defining your Prisma data model in server/prisma/schema.prisma
and your queries and actions in server/queries.js
and server/actions.js
respectively.
While Next.js API routes are a great tool for building APIs, Wasp currently doesn't support them directly. Instead, Wasp provides its own way of defining API endpoints (queries and actions), which are then automatically exposed over HTTP.
For example, here's how you might define a query in Wasp:
And here's how you might define the corresponding function in server/queries.js
:
For more complex use cases, Wasp also allows you to define custom API routes using Express.js, as discussed in this Github thread (https://github.com/wasp-lang/wasp/issues/268).
Sources:
- Wasp Documentation: Advanced APIs (https://wasp-lang.dev/docs/advanced/apis)
- Github Issue: Allow defining custom API routes (http) (https://github.com/wasp-lang/wasp/issues/268)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @senorioano, 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?I'd advise checking the Wasp tutorial to get the sense of the basics: https://wasp-lang.dev/docs/tutorial/create
Wasp is a backend + frontend + DB framework
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!
Yes I was checking the doc haha ^^
Thanks mate !
Since you are a member of the staff @miho . What about the apache license? Am I able to make money from my SAAS for "free"?
I'm not sure where you found the Apache licence? Both Wasp and Open Saas template are MIT licenced 😄
for real?
Wohooo @senorioano, you just became a Waspeteer level 2!
lemme see
I guess I did hallucinate. Not my best day haha