Quickstart
In this quickstart guide, you'll learn the typical workflow with Teo from creating an empty project, setting up a connection with a local database to sending HTTP requests with the generated query client.
Choose your stack
Before getting started, pick and select your own technical stack. And this guide will just be tailored for you. Also, your preferences are saved locally. The next time you open any documentation in our site, your tech stack preferences are preserved and restored for you.
Prerequisites
1. Create a new project and set up Teo
2. Connect to database and set up server
Create a file at project root directory named schema.teo
with the following
content:
Within this connector
config block, we specified the database to connect.
Next, let's declare a server
block to specify the port that this HTTP server
should be listening on. We specified the port value 5050
. Our server will be
listening on port 5050 after started.
Look at the request middlewares
thing. There is a middleware in the standard
library called logRequest
. It will log each incoming requests to the console.
3. Model your data in the schema
Now time for modeling data. Let's dive right in to declare some models.
Models in the Teo schema have two main purposes:
- Represent the tables or collections in the underlying database
- Represent a group of API resource including handler actions like
findMany
,findUnique
,create
, etc.
4. Generate query client
If you start the server with cargo teo serve
, you can already see server
started and listening on the desired port. Instead of writing each HTTP
request on the frontend, Teo can generate a client for you with great auto
completion.
Add this block into schema.teo
:
Now let's run this command to generate a brand new client.
5. Send HTTP requests with query client
Start a development server with this command:
Now navigate to the generated client and write some code to perform HTTP requests.
6. Next steps
In this Quickstart guide, you have a brief overview and understand how Teo
works. To learn further, read our
Beginner tutorial.
Feel free to explore the server & clients API a bit more on your own, e.g. by
including filtering, sorting, and pagination options in the findMany
requests or exploring more operations like update and delete objects.
Join the Teo community 💚
Teo is great and needs your support. Join us on Discord or ask questions via GitHub Discussions.