首页 文章 精选 留言 我的

精选列表

搜索[Bug修复],共10000篇文章
优秀的个人博客,低调大师

Teo 0.2.18 发布,修复代码生成 bug,巨好用的网络开发框架

一个后端框架,支持AI编写,不写编程代码就能启动服务器进行增删改查,还能为前端生成请求包,写一个登录功能只需5行代码。支持Node.js,支持Python,支持Rust。使用编程代码的话,它的ORM API可能是世界上最好用,最类型安全的。 使用方法 它的使用方法非常简单,一般我们在编写后端开发的时候,肯定离不开数据建模,编写各个类和表,我们就编写这个,就能得到默认的增删改查和分组聚合。 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 } 这就是最精简的博客网站的后台,用户和文章相关联。我们可以对用户和文章进行非常丰富的创建、编辑和查询等操作。 如果要创建一个用户的同时创建其相关联的文章,使用这个请求,发送到/User/create。 { "create": { "email": "ada@teocloud.io", "name": "Ada", "posts": { "create": [ { "title": "Introducing Teo", "content": "This post introduces Teo." }, { "title": "The next generation framework", "content": "Use the next generation technology." } ] } }, "include": { "posts": true } } 这样的返回值会包括用户,也包括文章。 { "data": { "id": 1, "email": "ada@teocloud.io", "name": "Ada", "posts": [ { "id": 1, "title": "Introducing Teo", "content": "This post introduces Teo.", "published": false, "authorId": 1 }, { "id": 2, "title": "The next generation framework", "content": "Use the next generation technology.", "published": false, "authorId": 1 } ] } } 5行代码编写登录 一个集成的登录只需要5行代码。请看演示: @identity.tokenIssuer($identity.jwt(expired: 3600 * 24 * 365)) @identity.jwtSecret(ENV["JWT_SECRET"]!) model User { @id @autoIncrement @readonly id: Int @unique @onSet($if($presents, $isEmail)) @identity.id email: String @writeonly @onSet($presents.bcrypt.salt) @identity.checker($get(.value).presents.bcrypt.verify($self.get(.password).presents)) password: String include handler identity.signIn include handler identity.identity } middlewares [identity.identityFromJwt(secret: ENV["JWT_SECRET"]!)] 这里的代码多于5行,是因为用户表的字段也在这段代码里。把这个请求发送到/User/signIn: { "credentials": { "email": "01@gmail.com", "password": "Aa123456" }} 我们得到了用户信息和他的token。 { "data": { "id": 1, "email": "01@gmail.com" }, "meta": { "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6eyJpZCI6MX0sIm1vZGVsIjpbIlVzZXIiXSwiZXhwIjoxNzQyMTI0NDk2fQ.x2DSIpdnUeJtsUOGQsHlGksr29aF-CWog6X5LILxsOc" }} 完整框架功能一个不少 文件上传,文件返回,静态目录映射,返回HTML页面,或是返回其他内容,一应俱全。Teo的插件是先进的先进后出插件,即第一个插件进入,第二个插件进入,执行路由定义,第二个插件退出,第一个插件退出。 要编写自定义路由,请看这里,这三段代码分别用Node.js,Python和Rust编写,选择你想选择的语言开发后台即可: import { App, Response, RequestCtx } from '@teocloud/teo' import { EchoPathArguments } from './entities' const app = new App() app.mainNamespace().defineHandler("hello", () => { return Response.html(` <html> <head> <title>Hello, Teo handlers</title> </head> <body> <h1>Hello, Teo handlers!</h1> </body> </html> `) }) app.mainNamespace().defineHandler("empty", () => { return Response.empty() }) app.mainNamespace().defineHandler("echo", (ctx: RequestCtx) => { const pathArguments: EchoPathArguments = ctx.pathArguments() return Response.string(pathArguments.data, "text/plain") }) app.run() from asyncio import run from teo import App, Response, RequestCtx from entities import EchoPathArguments async def main(): app = App() def hello_handler(_ctx): return Response.html(""" <html> <head> <title>Hello, Teo handlers</title> </head> <body> <h1>Hello, Teo handlers!</h1> </body> </html> """) app.main_namespace().define_handler("hello", hello_handler) def empty_handler(_ctx): return Response.empty() app.main_namespace().define_handler("empty", empty_handler) def echo_handler(ctx: RequestCtx): path_arguments: EchoPathArguments = ctx.path_arguments() return Response.string(path_arguments["data"], "text/plain") app.main_namespace().define_handler("echo", echo_handler) await app.run() run(main()) mod entities; use tokio::main; use teo::prelude::{App, Response, Result, path}; use crate::entities::EchoPathArguments; #[main] async fn main() -> Result<()> { let app = App::new()?; app.main_namespace_mut().define_handler("hello", || async { let response = Response::html(r#" <html> <head> <title>Hello, Teo handlers</title> </head> <body> <h1>Hello, Teo handlers!</h1> </body> </html> "#)?; Ok::<Response, Error>(response) }); app.main_namespace_mut().define_handler("empty", || async { Ok::<Response, Error>(Response::empty()) }); app.main_namespace_mut().define_handler("echo", |path_args: EchoPathArguments| async move { Ok::<Response, Error>(Response::string(path_args.data(), "text/plain")) }); app.run().await } 在这个例子中,我们定义了三个路由,返回HTML,返回空,和返回文本。 开始使用 Teo的安装过程非常简单,Node.js用npm、pnpm、yarn都可以安装,Python的用pip安装,Rust的用cargo安装,都是语言标配的包管理工具。 npm install @teocloud/teo # node.js pip install teo # python cargo install teo # rust 添加我们的微信群管微信caofz007,关注公众号,在Gitee上面给我们的辛苦劳动一点鼓励,点一颗星,即可加入我们微信群。群里你可以任意问答,我们有专人回复,我们的作者会聆听你的需求,为你改变框架的未来,开发你正需要的功能。 项目地址 官网:https://teocloud.io Gitee: https://gitee.com/teocloud/teo 学习资料 我们的作者花了数月的时间编写文档,我们的官网有详细的文档和教程,现在的浏览器翻译工具非常厉害,只要安装一个翻译插件,网站秒变中文,阅读轻松畅快。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册