GithubHelp home page GithubHelp logo

unity26org / wheel Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 4.0 158 KB

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

Home Page: http://wheel.unity26.org

License: MIT License

Go 100.00%
go golang api api-restful microservice backend

wheel's Introduction

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.

wheel's People

Contributors

adilsonchacon avatar felipesantiago avatar unity26org avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wheel's Issues

Fatal error if email configuration is not set

When user sign ups this error is showed:

[FATAL] 2020/02/08 22:17:17 dial tcp: lookup smtp.example.com: no such host
panic: dial tcp: lookup smtp.example.com: no such host

goroutine 47 [running]:
log.(*Logger).Panic(0xc00008a190, 0xc000099d70, 0x1, 0x1)
/usr/local/go/src/log/log.go:212 +0xbe
github.com/adilsonchacon/blog/commons/mailer.Send(0xc0002b6990, 0xc, 0xc0000926e0, 0x159, 0x1)
/home/acc/go/src/github.com/adilsonchacon/blog/commons/mailer/mailer.go:125 +0x6e9
created by github.com/adilsonchacon/blog/app/handlers.SessionSignUp
/home/acc/go/src/github.com/adilsonchacon/blog/app/handlers/session_handler.go:154 +0x352
exit status 2

Refactory for gitignore

Remove all lines about .AppleDouble and .DS_Store and substitute for simples ".AppleDouble" and ".DS_Store".

Change header "token" to "Authorization" for JWT

As an API consumer I want to the information "token" in header of the requests be changed to "Authorizarion" and its contents starts with "Bearer " to make it compatible with others systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.