Skip to content

Tool written in Go Language for developers to quickly and easily build scalable and lightweight APIs and microservices.

License

Notifications You must be signed in to change notification settings

unity26org/wheel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Wheel is a tool for creating and maintaining scalable and lightweight RESTful APIs. It runs through command line and generates codes (in Go Language), avoiding rework when designing the application architecture and maintenance.

Features

See full documentation of default features at http://wheel.unity26.org/features.html

Install

Go

Install Golang

Dependences

$> go get github.com/iancoleman/strcase
$> go get github.com/jinzhu/inflection

Wheel

$> go get github.com/unity26org/wheel
$> cd GOPATH/src/github.com/unity26org/wheel
$> go build -o wheel main.go 
$> sudo mv wheel /usr/bin

GOPATH is where the Go packages and sources are installed

The example above, the executable file was moved to /usr/bin. But feel free to set it up to any directory you want. Just add the path to your .profile, as you see below:

export PATH=$PATH:YOUR_DESIRED_PATH

Usage

Wheel has only two options: new to create new APIs and generate to add new functionalities to your API.

Check help for more details.

wheel --help

New API

Let's create an API for a Blog.

wheel new github.com/account_name/blog

It will output something like this:

"Go" seems installed
Checking dependences...
         ...
Generating new app...
         created: GOPATH/src/github.com/account_name/blog
         ...

Your RESTful API was successfully created!

Change to the root directory using the command line below: 
cd GOPATH/src/github.com/account_name/blog

Set up your database connection modifying the file config/database.yml

For more details call help:
go run main.go --help

Remember: GOPATH is where Go packages and sources are installed

Configure Your API

Database

Currently, Wheel has support only for Postgresql. Edit config/database.yml and set up your database connection.

Email

To connect to your email provider edit config/email.yml and set up with your send email account.

Application

Edit config/app.yml and set the following options:

Item Definition
app_name Your app name
app_repository Repository name
frontend_base_url URL to be used on your frontend
secret_key Key to encrypt passwords on database
reset_password_expiration_seconds After reset password, how long (in seconds) is it valid?
token_expiration_seconds After a JWT token is generated, how long (in seconds) is it valid?
locales List of available locales

Locales

Words and phrases for internacionalization. You can add your own locales files, but remember to add to config/app.yml configuration file first.

Running

Before running you must be sure your database schema is up to date, just run the migrate mode:

$> go run main.go --mode=migrate

Run:

$> go run main.go

Now go to http://localhost:8081 and you'll see:

{
  system_message: {
    type: "notice",
    content: "Yeah! Wheel is working!"
  }
}

See full documentation of default resources at http://wheel.unity26.org/default-resources.html

New CRUD

Based on the Blog API above, let's create a new CRUD.

Don't forget to call the directory where the application were generated.

cd GOPATH/src/github.com/account_name/blog
wheel g scaffold post title:string description:text published:bool user:references

It will output something like this:

"Go" seems installed
Checking dependences...
         ...
Generating new CRUD...
         created: app/entities/post_entity.go
         created: app/models/post/post_model.go
         created: app/models/post/post_view.go
         created: app/handlers/post_handler.go
         updated: routes/routes.go
         updated: db/schema/migrate.go
         updated: routes/authorize.go

After any changing, don't forget to run the migrate mode:

$> go run main.go --mode=migrate
$> go run main.go

Full Documentation

See full documentation at http://wheel.unity26.org/

License

Wheel is released under the MIT License.

About

Tool written in Go Language for developers to quickly and easily build scalable and lightweight APIs and microservices.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages