Comments (11)
Hi @akelyasir, create a file named .env
in the same directory: JWT_SECRET=mytopsecret
from teo.
Hi @akelyasir
Answer your questions.
- Integrate by yourself. Teo with custom programming code behaves just like any vanilla web frameworks.
- Temporarily cookie and session can't be accessed directly on the Request object. If you need it, I will add this feature in one day.
- Integrate by yourself. None of web frameworks provide email sender. Use an open source package to send.
- Use custom program feature of Teo.
- You can try it out with
teo generate admin
.
from teo.
Hi @victorteokw
Thank you very much for your answers. You have done a great job, congratulations. I'm still very new to the Rust programming language. I saw that you use actix-web based on Teo. I'm looking forward to your example and plugin about using cookie sessions. The reason I asked about Tera was because you were basically using actix-web, I was just wondering if it was possible to add it and it would be nice if it were. Of course, you know the system much better, I have just discovered Teo. I am thinking of integrating Rust Lettre regarding mail, but I would appreciate it if you could give me some information on where to start. Finally, I would be happy if you share whether it is possible to add all the features of Actix-web or everything integrated to Teo.
Thanks and regards
from teo.
Hi @akelyasir, if you send emails inside a route, just write route handler to handle email sending. Otherwise, use custom pipeline item. Follow the 4 tutorials from the official docs: https://docs.teodev.io/getting-started/beginner-tutorial/write-a-schema-only-app, and you will be able to write custom pipeline item.
from teo.
I will add sessions and cookies tomorrow. A new version will be published.
from teo.
thank you for your interest I tried to create it with the cargo teo generate admin
command, but there was no result. Do I need to make any extra settings? How can I reach
from teo.
Hi @akelyasir, try this demo, replace schema.teo with this:
connector {
// SQLite
// provider: .sqlite,
// url: "sqlite:./database.sqlite",
// MySQL
// provider: .mysql,
// url: "mysql://localhost:3306/adminbackend",
// PostgreSQL
provider: .postgres,
url: "postgres://localhost:5432/adminbackend",
}
server {
bind: ("0.0.0.0", 5052)
}
admin {
dest: "../teo-admin-dev",
host: .inject("process.env.TEO_HOST"),
languages: [.enUs, .enUk, .de, .es, .fr, .he, .hi, .ja, .ko, .zhCn, .zhTw]
}
@identity.tokenIssuer($identity.jwt(expired: 3600 * 24 * 365))
@identity.jwtSecret(ENV["JWT_SECRET"]!) @admin.administrator
model Root {
@id @autoIncrement @readonly
id: Int
@unique @onSet($if($presents, $isEmail)) @identity.id
email: String
@writeonly @onSet($presents.bcrypt.salt) @admin.secureInput
@identity.checker($get(.value).presents.bcrypt.verify($self.get(.password).presents))
password: String
include handler identity.signIn
include handler identity.identity
}
@identity.tokenIssuer($identity.jwt(expired: 3600 * 24 * 365))
@identity.jwtSecret(ENV["JWT_SECRET"]!) @admin.administrator
model Admin {
@id @autoIncrement @readonly
id: Int
@unique @onSet($if($presents, $isEmail)) @identity.id
email: String
@unique @identity.id
phoneNo: String
@writeonly @onSet($presents.bcrypt.salt) @admin.secureInput
@identity.checker($get(.value).presents.bcrypt.verify($self.get(.password).presents))
password: String
include handler identity.signIn
include handler identity.identity
}
model Item {
@id @autoIncrement @readonly
id: Int
@admin.title
name: String
}
model Product {
@id @autoIncrement @readonly
id: Int
name: String
stock: Int
@foreignKey
categoryId: Int
@relation(fields: .categoryId, references: .id)
category: Category
}
model Category {
@id @autoIncrement @readonly
id: Int
name: String
@relation(fields: .id, references: .categoryId)
products: Product[]
}
enum Sex {
male
female
}
model Record {
@id @autoIncrement @readonly
id: Int
string: String
bool: Bool
int: Int
float: Float
decimal: Decimal
date: Date
dateTime: DateTime
sex: Sex
strings: String[]
genders: Sex[]
}
middlewares [identity.identityFromJwt(secret: ENV["JWT_SECRET"]!)]
autoseed dataset default {
group Admin {
record admin {
email: "[email protected]",
phoneNo: "13588888888",
password: "Aa123456"
}
}
group Root {
record root {
email: "[email protected]",
password: "Aa123456"
}
}
}
from teo.
Remove array type fields if you are not using PostgreSQL.
from teo.
Hi @akelyasir, I added cookies to the Rust Request object. However, it's a bit cumbersome to add it to the Response object. In the future 0.3.0 version, we will use hyper to rewrite the HTTP layer. At that time, full features of cookies will be supported.
from teo.
Hi @victorteokw
Thank you for your attention. I couldn't run the schema you sent and couldn't find the problem.
Error: Error { code: 500, message: "teo_result::Error: {\"code\":500,\"message\":\"Cannot convert Null into String\",\"errors\":null}", errors: None, platform_native_object: None }
I am getting an error like this. I am using Postgresql.
connector {
provider: .postgres,
url: "postgres://username:password@localhost:5432/database",
}
from teo.
Hi @victorteokw
Thank you very much. I forgot to create the env file.
from teo.
Related Issues (20)
- Add examples to Teo CLI reference
- Add "See also" links to Teo concepts documentation especially CLI concepts
- Add command "teo run --list" HOT 1
- Update page titles in documentation pages
- BigQuery support HOT 7
- Copy license and code of conduct to each of our repos except deprecated ones
- Authentication and authorization Support HOT 2
- Connect to MongoDB replica set
- Teo(v0.2.15) ganerate entity and client panic HOT 1
- Parser: No errors displaying for empty model without primary key
- Parser: foreign key type unmatch error
- Add `select` and `include` to identity template handler
- MongoDB: connector is not using table name HOT 1
- Runtime: display error if ENV value is null and !
- Bug: virtual fields are created when creating table HOT 6
- Schema bug HOT 2
- User security question HOT 3
- File Upload example bug HOT 6
- Teo runtime build error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teo.