Skip to content

Commit 0e7bf27

Browse files
committed
0.2.33
1 parent 32d6474 commit 0e7bf27

File tree

3 files changed

+183
-16
lines changed

3 files changed

+183
-16
lines changed

Cargo.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "teo-py"
3-
version = "0.2.32"
3+
version = "0.2.33"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -9,7 +9,7 @@ name = "teo"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
teo = { version = "0.2.32" }
12+
teo = { version = "0.2.33" }
1313
teo-result = { version = "0.2.23", features = ["pyo3"] }
1414
pyo3 = { version = "0.20.3", features = ["extension-module", "chrono", "indexmap"] }
1515
pyo3-asyncio = { version = "0.20.0", features = ["attributes", "tokio-runtime"] }

README.md

+176-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,192 @@
1-
Teo Python
2-
==========
1+
<div align="center">
2+
<h1>Teo</h1>
3+
<a href="https://crates.io/crates/teo"><img src="https://img.shields.io/crates/v/teo?style=flat-square" /></a>
4+
<a href="https://www.npmjs.com/package/@teocloud/teo"><img src="https://img.shields.io/npm/v/%40teocloud%2Fteo?style=flat-square" /></a>
5+
<a href="https://pypi.org/project/teo/"><img src="https://img.shields.io/pypi/v/teo?style=flat-square" /></a>
6+
<a href="https://marketplace.visualstudio.com/items?itemName=yeannylam.teo-vscode"><img src="https://img.shields.io/visual-studio-marketplace/v/yeannylam.teo-vscode?style=flat-square&label=VSCode%20marketplace&color=%2300AFD7" /></a>
7+
<a href="https://github.com/teocloud/teo/blob/master/LICENSE"><img src="https://img.shields.io/github/license/teocloud/teo.svg?style=flat-square" /></a>
8+
<a href="https://github.com/teocloud/teo"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" /></a>
9+
<br />
10+
<br />
11+
<div><strong>Schema-centered</strong> next-generation web framework for Rust, Node.js and Python.</div>
12+
<br />
13+
<a href="https://docs.teodev.io/getting-started/quickstart">Quickstart</a>
14+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
15+
<a href="https://teodev.io/">Official website</a>
16+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
17+
<a href="https://docs.teodev.io/">Docs</a>
18+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
19+
<a href="https://blog.teodev.io">Blog</a>
20+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
21+
<a href="https://teodev.io/discord">Discord</a>
22+
<br />
23+
<hr />
24+
</div>
325

4-
Run Teo server and write custom callbacks with Python.
26+
## Introduction
527

6-
## Installation
28+
Teo is a **schema-centered** next-generation web framework for Rust, Node.js and Python.
29+
30+
## Highlights & Features
31+
32+
* Innovative schema definition inspired by GraphQL and Prisma
33+
* Auto database migration
34+
* Supports Rust, Node.js and Python
35+
* Supports MySQL, PostgreSQL, SQLite and MongoDB
36+
* Generated ORM types and interfaces
37+
* Generated query clients for frontend
38+
* Very efficient and performant
39+
* Data sanitization, transformation and validation
40+
* Builtin user sessions
41+
* Builtin permission check
42+
* First in last out middlewares
43+
* Custom routes and handlers
44+
* Generated customizable admin dashboard
45+
46+
## Getting started
47+
48+
The fastest way to get started with Teo is by following the [Quickstart guide](https://docs.teodev.io/getting-started/quickstart).
49+
50+
### Installation
51+
52+
Install Node.js edition.
53+
54+
```sh
55+
npm install @teocloud/teo
56+
```
57+
58+
Install Python edition.
759

860
```sh
961
pip install teo
1062
```
1163

12-
## Example
64+
Install Rust edition.
1365

14-
```python
15-
from asyncio import run
16-
from teo import App
66+
```sh
67+
cargo install teo
68+
```
69+
70+
### Write a schema-only server
71+
72+
To write a server is quite simple with Teo. Create a file named `schema.teo`.
73+
Specify which database to connect and which port to listen.
74+
75+
```teo
76+
connector {
77+
provider: .sqlite,
78+
url: "sqlite::memory:"
79+
}
80+
81+
server {
82+
bind: ("0.0.0.0", 5050)
83+
}
84+
85+
model User {
86+
@id @autoIncrement @readonly
87+
id: Int
88+
@unique @onSet($if($presents, $isEmail))
89+
email: String
90+
name: String?
91+
@relation(fields: .id, references: .authorId)
92+
posts: Post[]
93+
}
94+
95+
model Post {
96+
@id @autoIncrement @readonly
97+
id: Int
98+
title: String
99+
content: String?
100+
@default(false)
101+
published: Bool
102+
@foreignKey
103+
authorId: Int
104+
@relation(fields: .authorId, references: .id)
105+
author: User
106+
}
107+
```
108+
109+
Start the server with `teo serve` command. Now you can create, update, delete,
110+
read, aggregate and group by. Read our
111+
[Query client guide](https://docs.teodev.io/guides/query-client-guides/crud)
112+
for detailed usage.
113+
114+
### Write custom handlers
17115

116+
Declare the handler in the schema.
18117

118+
```teo
119+
@map(.get, "/echo/:data", interface: "EchoPathArguments")
120+
declare nonapi handler echo(): Any
121+
```
122+
123+
Implement the handler with program code.
124+
125+
#### Node.js implementation
126+
127+
```ts
128+
import { App, Response, RequestCtx } from '@teocloud/teo'
129+
import { EchoPathArguments } from './entities'
130+
131+
const app = new App()
132+
app.mainNamespace().defineHandler("echo", (ctx: RequestCtx) => {
133+
const pathArguments: EchoPathArguments = ctx.pathArguments()
134+
return Response.string(pathArguments.data, "text/plain")
135+
})
136+
app.run()
137+
```
138+
139+
#### Python implementation
140+
141+
```python
142+
from asyncio import run
143+
from teo import App, Response, RequestCtx
144+
from entities import EchoPathArguments
145+
19146
async def main():
20147
app = App()
148+
def echo_handler(ctx: RequestCtx):
149+
path_arguments: EchoPathArguments = ctx.path_arguments()
150+
return Response.string(path_arguments["data"], "text/plain")
151+
app.main_namespace().define_handler("echo", echo_handler)
21152
await app.run()
153+
154+
run(main())
155+
```
22156

157+
#### Rust implementation
23158

24-
run(main())
159+
```rust
160+
mod entities;
161+
162+
use tokio::main;
163+
use teo::prelude::{App, Response, Result, path};
164+
use crate::entities::EchoPathArguments;
165+
166+
#[main]
167+
async fn main() -> Result<()> {
168+
let app = App::new()?;
169+
app.main_namespace_mut().define_handler("echo", |path_args: EchoPathArguments| async move {
170+
Ok::<Response, Error>(Response::string(path_args.data(), "text/plain"))
171+
});
172+
app.run().await
173+
}
25174
```
175+
176+
## Tutorials
177+
178+
We prepared a [Beginner tutorial series](https://docs.teodev.io/getting-started/beginner-tutorial/write-a-schema-only-app)
179+
to help you learn and understand Teo.
180+
181+
## Issues
182+
183+
Welcome to submit issues in this repo.
184+
185+
## Contributing
186+
187+
Read our [Contributing guide](https://github.com/teocloud/teo/blob/main/CONTRIBUTING.md)
188+
to set projects up and start contributing.
189+
190+
## License
191+
192+
TEO is under Apache 2.0 license.

0 commit comments

Comments
 (0)