try an SDK and a manually defined lang
I don't think I like the SDK way, and langV2 seems to be so simialr to V1 that I'm probably going to stick with V1 for now and see if i can get it to do what I need.
This commit is contained in:
136
examples/sdk/debug_sdk.go
Normal file
136
examples/sdk/debug_sdk.go
Normal file
@ -0,0 +1,136 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"masonry/sdk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
userEntity := sdk.Entity{
|
||||
Name: "User",
|
||||
Description: nil,
|
||||
Fields: []sdk.Field{
|
||||
{
|
||||
Name: "id",
|
||||
Type: "int",
|
||||
Required: true,
|
||||
Unique: true,
|
||||
Default: nil,
|
||||
Validations: []sdk.Validation{
|
||||
{
|
||||
Type: "validate",
|
||||
Value: nil,
|
||||
},
|
||||
},
|
||||
Relationship: nil,
|
||||
},
|
||||
{
|
||||
Name: "username",
|
||||
Type: "string",
|
||||
Required: true,
|
||||
Unique: true,
|
||||
Default: nil,
|
||||
Validations: []sdk.Validation{
|
||||
{
|
||||
Type: "validate",
|
||||
Value: nil,
|
||||
},
|
||||
},
|
||||
Relationship: nil,
|
||||
},
|
||||
{
|
||||
Name: "email",
|
||||
Type: "string",
|
||||
Required: true,
|
||||
Unique: true,
|
||||
Default: nil,
|
||||
Validations: []sdk.Validation{
|
||||
{
|
||||
Type: "validate",
|
||||
Value: nil,
|
||||
},
|
||||
},
|
||||
Relationship: nil,
|
||||
},
|
||||
{
|
||||
Name: "password",
|
||||
Type: "string",
|
||||
Required: true,
|
||||
Unique: false,
|
||||
Default: nil,
|
||||
Validations: []sdk.Validation{
|
||||
{
|
||||
Type: "validate",
|
||||
Value: nil,
|
||||
},
|
||||
},
|
||||
Relationship: nil,
|
||||
},
|
||||
{
|
||||
Name: "created_at",
|
||||
Type: "datetime",
|
||||
Required: true,
|
||||
Unique: false,
|
||||
Default: nil,
|
||||
Validations: []sdk.Validation{
|
||||
{
|
||||
Type: "validate",
|
||||
Value: nil,
|
||||
},
|
||||
},
|
||||
Relationship: nil,
|
||||
},
|
||||
{
|
||||
Name: "updated_at",
|
||||
Type: "datetime",
|
||||
Required: true,
|
||||
Unique: false,
|
||||
Default: nil,
|
||||
Validations: []sdk.Validation{
|
||||
{
|
||||
Type: "validate",
|
||||
Value: nil,
|
||||
},
|
||||
},
|
||||
Relationship: nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
createUserDesc := "Create a new user with username, email, and password. Returns the created user object."
|
||||
createUser := sdk.Endpoint{
|
||||
Method: "POST",
|
||||
Path: "/user",
|
||||
Entity: userEntity,
|
||||
Description: &createUserDesc,
|
||||
Auth: true,
|
||||
Permissions: nil,
|
||||
}
|
||||
|
||||
server := sdk.Server{
|
||||
Name: "TestServer",
|
||||
Settings: []sdk.ServerSetting{
|
||||
{
|
||||
Host: "localhost",
|
||||
Port: 8000,
|
||||
},
|
||||
},
|
||||
Endpoints: []sdk.Endpoint{
|
||||
createUser,
|
||||
},
|
||||
}
|
||||
|
||||
def := sdk.Definition{
|
||||
Server: []sdk.Server{
|
||||
server,
|
||||
},
|
||||
}
|
||||
|
||||
out, err := json.MarshalIndent(def, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
println(string(out))
|
||||
println("🎉 Successfully built SDK definition!")
|
||||
println("You can now use this SDK definition in your application.")
|
||||
}
|
Reference in New Issue
Block a user