Skip to content

Commit 2e033de

Browse files
committed
0.2.33
1 parent ca87efa commit 2e033de

File tree

4 files changed

+181
-21
lines changed

4 files changed

+181
-21
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
edition = "2021"
33
name = "teocloud_teo"
4-
version = "0.2.32"
4+
version = "0.2.33"
55

66
[lib]
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
teo = { version = "0.2.32" }
10+
teo = { version = "0.2.33" }
1111
teo-result = { version = "0.2.23", features = ["napi"] }
1212
napi = { version = "2.16.0", default-features = false, features = ["napi5", "async", "chrono_date", "compat-mode"] }
1313
napi-derive = "2.16.0"

README.md

Lines changed: 173 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,192 @@
1-
Teo Node.js
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 URL route handlers with Node.js.
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.
753

854
```sh
955
npm install @teocloud/teo
1056
```
1157

12-
## Example
58+
Install Python edition.
59+
60+
```sh
61+
pip install teo
62+
```
63+
64+
Install Rust edition.
65+
66+
```sh
67+
cargo install teo
68+
```
1369

14-
Write with JavaScript:
70+
### Write a schema-only server
1571

16-
```javascript
17-
const { App } = require("@teocloud/teo")
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.
1874

19-
const app = new App()
20-
app.run()
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+
```
21108

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
115+
116+
Declare the handler in the schema.
117+
118+
```teo
119+
@map(.get, "/echo/:data", interface: "EchoPathArguments")
120+
declare nonapi handler echo(): Any
22121
```
23122

24-
Write with TypeScript:
123+
Implement the handler with program code.
25124

26-
```typescript
27-
import { App } from "@teocloud/teo"
125+
#### Node.js implementation
28126

127+
```ts
128+
import { App, Response, RequestCtx } from '@teocloud/teo'
129+
import { EchoPathArguments } from './entities'
130+
29131
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+
})
30136
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+
146+
async def main():
147+
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)
152+
await app.run()
153+
154+
run(main())
155+
```
156+
157+
#### Rust implementation
31158

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+
}
32174
```
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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@teocloud/teo",
3-
"version": "0.2.32",
3+
"version": "0.2.33",
44
"main": "index.js",
55
"types": "index.d.ts",
66
"napi": {

0 commit comments

Comments
 (0)