-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f0b9197
Showing
16 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
app_root: . | ||
ignored_folders: | ||
- vendor | ||
- log | ||
- logs | ||
- assets | ||
- public | ||
- grifts | ||
- tmp | ||
- bin | ||
- node_modules | ||
- .sass-cache | ||
included_extensions: | ||
- .go | ||
- .env | ||
build_path: tmp | ||
build_delay: 200ns | ||
binary_name: swagip-build | ||
command_flags: [] | ||
enable_colors: true | ||
log_name: buffalo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
engines: | ||
fixme: | ||
enabled: true | ||
gofmt: | ||
enabled: true | ||
golint: | ||
enabled: true | ||
govet: | ||
enabled: true | ||
exclude_paths: | ||
- grifts/**/* | ||
- "**/*_test.go" | ||
- "*_test.go" | ||
- "**_test.go" | ||
- logs/* | ||
- public/* | ||
- templates/* | ||
ratings: | ||
paths: | ||
- "**.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
*.log | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
vendor/ | ||
**/*.log | ||
**/*.sqlite | ||
.idea/ | ||
bin/ | ||
tmp/ | ||
node_modules/ | ||
.sass-cache/ | ||
*-packr.go | ||
public/assets/ | ||
swagip | ||
.vscode/ | ||
.grifter/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
before_script: | ||
- ln -s /builds /go/src/$(echo "github.com/StackFocus/swagip" | cut -d "/" -f1) | ||
- cd /go/src/github.com/StackFocus/swagip | ||
- mkdir -p public/assets | ||
- go get -u github.com/gobuffalo/buffalo/buffalo | ||
- go get -t -v ./... | ||
- export PATH="$PATH:$GOPATH/bin" | ||
|
||
stages: | ||
- test | ||
|
||
.test-vars: &test-vars | ||
variables: | ||
GO_ENV: "test" | ||
|
||
# Golang version choice helper | ||
.use-golang-image: &use-golang-latest | ||
image: golang:latest | ||
|
||
.use-golang-image: &use-golang-1-8 | ||
image: golang:1.8 | ||
|
||
test: | ||
# Change to "<<: *use-golang-latest" to use the latest Go version | ||
<<: *use-golang-1-8 | ||
<<: *test-vars | ||
stage: test | ||
script: | ||
- buffalo test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This is a multi-stage Dockerfile and requires >= Docker 17.05 | ||
# https://docs.docker.com/engine/userguide/eng-image/multistage-build/ | ||
FROM gobuffalo/buffalo:v0.12.4 as builder | ||
|
||
RUN mkdir -p $GOPATH/src/github.com/StackFocus/swagip | ||
WORKDIR $GOPATH/src/github.com/StackFocus/swagip | ||
|
||
ADD . . | ||
RUN go get $(go list ./... | grep -v /vendor/) | ||
RUN buffalo build --static -o /bin/app | ||
|
||
FROM alpine | ||
RUN apk add --no-cache bash | ||
RUN apk add --no-cache ca-certificates | ||
|
||
WORKDIR /bin/ | ||
|
||
COPY --from=builder /bin/app . | ||
|
||
# Uncomment to run the binary in "production" mode: | ||
# ENV GO_ENV=production | ||
|
||
# Bind the app to 0.0.0.0 so it can be seen from outside the container | ||
ENV ADDR=0.0.0.0 | ||
|
||
EXPOSE 3000 | ||
|
||
# Uncomment to run the migrations before running the binary: | ||
# CMD /bin/app migrate; /bin/app | ||
CMD exec /bin/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Welcome to Buffalo! | ||
|
||
Thank you for choosing Buffalo for your web development needs. | ||
|
||
## Starting the Application | ||
|
||
Buffalo ships with a command that will watch your application and automatically rebuild the Go binary and any assets for you. To do that run the "buffalo dev" command: | ||
|
||
$ buffalo dev | ||
|
||
If you point your browser to [http://127.0.0.1:3000](http://127.0.0.1:3000) you should see a "Welcome to Buffalo!" page. | ||
|
||
**Congratulations!** You now have your Buffalo application up and running. | ||
|
||
## What Next? | ||
|
||
We recommend you heading over to [http://gobuffalo.io](http://gobuffalo.io) and reviewing all of the great documentation there. | ||
|
||
Good luck! | ||
|
||
[Powered by Buffalo](http://gobuffalo.io) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package actions | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gobuffalo/packr" | ||
"github.com/gobuffalo/suite" | ||
) | ||
|
||
type ActionSuite struct { | ||
*suite.Action | ||
} | ||
|
||
func Test_ActionSuite(t *testing.T) { | ||
action, err := suite.NewActionWithFixtures(App(), packr.NewBox("../fixtures")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
as := &ActionSuite{ | ||
Action: action, | ||
} | ||
suite.Run(t, as) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package actions | ||
|
||
import ( | ||
"github.com/gobuffalo/buffalo" | ||
"github.com/gobuffalo/buffalo/middleware" | ||
"github.com/gobuffalo/buffalo/middleware/ssl" | ||
"github.com/gobuffalo/envy" | ||
"github.com/unrolled/secure" | ||
|
||
"github.com/gobuffalo/x/sessions" | ||
"github.com/rs/cors" | ||
) | ||
|
||
// ENV is used to help switch settings based on where the | ||
// application is being run. Default is "development". | ||
var ENV = envy.Get("GO_ENV", "development") | ||
var app *buffalo.App | ||
|
||
// App is where all routes and middleware for buffalo | ||
// should be defined. This is the nerve center of your | ||
// application. | ||
func App() *buffalo.App { | ||
if app == nil { | ||
app = buffalo.New(buffalo.Options{ | ||
Env: ENV, | ||
SessionStore: sessions.Null{}, | ||
PreWares: []buffalo.PreWare{ | ||
cors.Default().Handler, | ||
}, | ||
SessionName: "_swagip_session", | ||
}) | ||
// Automatically redirect to SSL | ||
app.Use(forceSSL()) | ||
|
||
// Set the request content type to JSON | ||
app.Use(middleware.SetContentType("application/json")) | ||
|
||
if ENV == "development" { | ||
app.Use(middleware.ParameterLogger) | ||
} | ||
|
||
app.GET("/", HomeHandler) | ||
|
||
} | ||
|
||
return app | ||
} | ||
|
||
// forceSSL will return a middleware that will redirect an incoming request | ||
// if it is not HTTPS. "http://example.com" => "https://example.com". | ||
// This middleware does **not** enable SSL. for your application. To do that | ||
// we recommend using a proxy: https://gobuffalo.io/en/docs/proxy | ||
// for more information: https://github.com/unrolled/secure/ | ||
func forceSSL() buffalo.MiddlewareFunc { | ||
return ssl.ForceSSL(secure.Options{ | ||
SSLRedirect: ENV == "production", | ||
SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package actions | ||
|
||
import "github.com/gobuffalo/buffalo" | ||
|
||
// HomeHandler is a default handler to serve up | ||
// a home page. | ||
func HomeHandler(c buffalo.Context) error { | ||
return c.Render(200, r.JSON(map[string]string{"message": "Welcome to Buffalo!"})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package actions | ||
|
||
func (as *ActionSuite) Test_HomeHandler() { | ||
res := as.JSON("/").Get() | ||
as.Equal(200, res.Code) | ||
as.Contains(res.Body.String(), "Welcome to Buffalo") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package actions | ||
|
||
import ( | ||
"github.com/gobuffalo/buffalo/render" | ||
) | ||
|
||
var r *render.Engine | ||
|
||
func init() { | ||
r = render.New(render.Options{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[[scenario]] | ||
name = "lots of widgets" | ||
|
||
[[scenario.table]] | ||
name = "widgets" | ||
|
||
[[scenario.table.row]] | ||
id = "<%= uuidNamed("widget") %>" | ||
name = "This is widget #1" | ||
body = "some widget body" | ||
created_at = "<%= now() %>" | ||
updated_at = "<%= now() %>" | ||
|
||
[[scenario.table.row]] | ||
id = "<%= uuid() %>" | ||
name = "This is widget #2" | ||
body = "some widget body" | ||
created_at = "<%= now() %>" | ||
updated_at = "<%= now() %>" | ||
|
||
[[scenario.table]] | ||
name = "users" | ||
|
||
[[scenario.table.row]] | ||
id = "<%= uuid() %>" | ||
name = "Mark Bates" | ||
admin = true | ||
age = 41 | ||
widget_id = "<%= uuidNamed("widget") %>" | ||
created_at = "<%= now() %>" | ||
updated_at = "<%= now() %>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package grifts | ||
|
||
import ( | ||
"github.com/StackFocus/swagip/actions" | ||
"github.com/gobuffalo/buffalo" | ||
) | ||
|
||
func init() { | ||
buffalo.Grifts(actions.App()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singular": "plural" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/StackFocus/swagip/actions" | ||
) | ||
|
||
// main is the starting point to your Buffalo application. | ||
// you can feel free and add to this `main` method, change | ||
// what it does, etc... | ||
// All we ask is that, at some point, you make sure to | ||
// call `app.Serve()`, unless you don't want to start your | ||
// application that is. :) | ||
func main() { | ||
app := actions.App() | ||
if err := app.Serve(); err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
/* | ||
# Notes about `main.go` | ||
## SSL Support | ||
We recommend placing your application behind a proxy, such as | ||
Apache or Nginx and letting them do the SSL heaving lifting | ||
for you. https://gobuffalo.io/en/docs/proxy | ||
## Buffalo Build | ||
When `buffalo build` is run to compile your binary this `main` | ||
function will be at the heart of that binary. It is expected | ||
that your `main` function will start your application using | ||
the `app.Serve()` method. | ||
*/ |