Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Schema-driven web server framework.

License

NotificationsYou must be signed in to change notification settings

teodevgroup/teo

Repository files navigation



Schema-driven web server framework.

Quickstart  •  Official website  •  Docs  •  Blog  •  Discord

Introduction

Teo isschema-driven web server framework. The server side API is native to Rust, Node.js and Python.

Highlights & Features

  • Native toRust,Node.js andPython
  • Innovative schema definition inspired byGraphQL andPrisma
  • Auto database migration
  • SupportsMySQL,PostgreSQL,SQLite andMongoDB
  • GeneratedORM types and interfaces
  • Generatedquery clients for frontend
  • Very efficient and performant
  • Data sanitization, transformation and validation
  • Builtin usersessions
  • Builtinpermission check
  • First in last outmiddlewares
  • Customroute handlers
  • Generated customizableadmin dashboard
  • Plays great with AI tools

Getting started

The fastest way to get started with Teo is by following theQuickstart guide.

Installation

Install Node.js edition.

npm install @teodevgroup/teo

Install Python edition.

pip install teo

Install Rust edition.

cargo install teo

Write a schema-only server

To write a server is quite simple with Teo. Create a file namedschema.teo.Specify which database to connect and which port to listen.

connector {  provider: .sqlite,  url: "sqlite::memory:"} server {  bind: ("0.0.0.0", 5050)} model User {  @id @autoIncrement @readonly  id: Int  @unique @onSet($if($presents, $isEmail))  email: String  name: String?  @relation(fields: .id, references: .authorId)  posts: Post[]} model Post {  @id @autoIncrement @readonly  id: Int  title: String  content: String?  @default(false)  published: Bool  @foreignKey  authorId: Int  @relation(fields: .authorId, references: .id)  author: User}

Start the server withteo serve command. Now you can create, update, delete,read, aggregate and group by. Read ourQuery client guidefor detailed usage.

Write custom handlers

Declare the handler in the schema.

@map(.get, "/echo/:data", interface: "EchoCaptures")declare nonapi handler echo(): Any

Implement the handler with program code.

Node.js implementation

import{App,Response,Request}from'@teodevgroup/teo'import{EchoCaptures}from'./entities'constapp=newApp()app.mainNamespace().defineHandler("echo",(request:Request)=>{constcaptures:EchoCaptures=request.captures()returnResponse.string(captures.data,"text/plain")})app.run()

Python implementation

fromasyncioimportrunfromteoimportApp,Response,RequestfromentitiesimportEchoCapturesasyncdefmain():app=App()defecho_handler(request:Request):captures:EchoCaptures=request.captures()returnResponse.string(captures["data"],"text/plain")app.main_namespace.define_handler("echo",echo_handler)awaitapp.run()run(main())

Rust implementation

mod entities;use tokio::main;use teo::prelude::{App,Response,Result, path};usecrate::entities::EchoCaptures;#[main]asyncfnmain() ->Result<()>{let app =App::new()?;    app.main_namespace().define_handler("echo", |captures:EchoCaptures|asyncmove{Ok::<Response,Error>(Response::string(captures.data(),"text/plain"))});    app.run().await}

Tutorials

We prepared aBeginner tutorial seriesto help you learn and understand Teo.

Issues

Welcome to submit issues in this repo.

Contributing

Read ourContributing guideto set projects up and start contributing.

License

TEO is under Apache 2.0 license.


[8]ページ先頭

©2009-2025 Movatter.jp