Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Here you can find the most **delicious** recipes to cook delicious meals using o
- [I18n](./i18n/README.md) - Internationalization support.
- [JWT](./jwt/README.md) - Using JSON Web Tokens (JWT) for authentication.
- [Kubernetes](./k8s/README.md) - Deploying applications to Kubernetes.
- [Local Development with Testcontainers](./local-development-testcontainers/README.md) - Local development with Testcontainers.
- [Todo App + Auth + GORM + Testcontainers](./local-development-testcontainers/README.md) - A Todo application with authentication using GORM and Postgres.
- [Memgraph](./memgraph/README.md) - Using Memgraph.
- [MinIO](./minio/README.md) - A simple application for uploading and downloading files from MinIO.
- [MongoDB](./mongodb/README.md) - Connecting to a MongoDB database.
Expand All @@ -76,6 +76,7 @@ Here you can find the most **delicious** recipes to cook delicious meals using o
- [React](./react-router/README.md) - Using React.
- [Recover Middleware](./recover/README.md) - Recover middleware for error handling.
- [RSS Feed](./rss-feed/README.md) - Generating an RSS feed.
- [Seenode](./seenode/README.md) - Deploying to Seenode cloud platform.
- [Server Timing](./server-timing/README.md) - Adding Server Timing headers to an application.
- [Sessions + SQLite3](./sessions-sqlite3/README.md) - Using SQLite3 as a storage engine for user sessions.
- [Socketio](./socketio/README.md) - A chatroom application using Socket.IO.
Expand Down
2 changes: 1 addition & 1 deletion local-development-testcontainers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: A Todo application with authentication using GORM and Postgres.

# Todo App with Auth using GORM and Testcontainers

[![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/todo-app-testcontainers-postgres) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github.com/gofiber/recipes/tree/master/todo-app-testcontainers-postgres)
[![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/local-development-testcontainers) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github/gofiber/recipes/tree/master/local-development-testcontainers)

This project demonstrates a Todo application with authentication using GORM and Testcontainers.

Expand Down
87 changes: 87 additions & 0 deletions seenode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: Seenode
keywords: [seenode, deploy, cloud]
description: Deploying to Seenode cloud platform.
---

# Seenode Deployment Example

[![Github](https://img.shields.io/static/v1?label=&message=Github&color=2ea44f&style=for-the-badge&logo=github)](https://github.com/gofiber/recipes/tree/master/seenode) [![StackBlitz](https://img.shields.io/static/v1?label=&message=StackBlitz&color=2ea44f&style=for-the-badge&logo=StackBlitz)](https://stackblitz.com/github/gofiber/recipes/tree/master/seenode)

This project demonstrates how to deploy a Go application using the Fiber framework on Seenode.

## Prerequisites

Ensure you have the following installed:

- Golang
- [Fiber](https://github.com/gofiber/fiber) package
- [Seenode account](https://cloud.seenode.com)

## Setup

1. Clone the repository:
```sh
git clone https://github.com/gofiber/recipes.git
cd recipes/seenode
```

2. Install dependencies:
```sh
go get

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While go get works, the more idiomatic command with Go modules to ensure all dependencies are present and go.mod/go.sum are tidy is go mod tidy.

Suggested change
go get
go mod tidy

```

3. Create a Seenode account and connect your repository:
- Go to [Seenode Dashboard](https://cloud.seenode.com)
- Create a new Web Service
- Connect your Git repository

4. Configure deployment:
- **Build Command**: `go build -o app main.go`
- **Start Command**: `./app`

5. Deploy the application:
```sh
git add .
git commit -m "Deploy to Seenode"
git push
```

## Running the Application

1. Open the application in your browser using the provided Seenode URL.

## Example

Here is an example `main.go` file for the Fiber application:

```go
package main
import (
"fmt"
"os"
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, Welcome to seenode 👋")
})
port := os.Getenv("PORT")
if port == "" {
port = "80"
}
app.Listen(fmt.Sprintf(":%s", port))
}
```
## References
- [Fiber Documentation](https://docs.gofiber.io)
- [Seenode Documentation](https://seenode.com/docs/frameworks/go/fiber/)
- [Seenode Dashboard](https://cloud.seenode.com)
19 changes: 19 additions & 0 deletions seenode/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module seenode-example

go 1.23

require github.com/gofiber/fiber/v2 v2.52.9

require (
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/sys v0.28.0 // indirect
)
27 changes: 27 additions & 0 deletions seenode/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw=
github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA=
github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
22 changes: 22 additions & 0 deletions seenode/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
"os"
"github.com/gofiber/fiber/v2"
)

func main() {
app := fiber.New()

app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, Welcome to seenode 👋")
})

port := os.Getenv("PORT")
if port == "" {
port = "80"
}

app.Listen(fmt.Sprintf(":%s", port))
}
Comment on lines 1 to 25

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This is a good start for the example application. I have a couple of suggestions to make it more robust and align with common Go practices:

  1. Default Port: The default port 80 is a privileged port on Unix-like systems and requires root privileges. It's better to use a non-privileged port like 8080 for local development.
  2. Error Handling: The app.Listen function can return an error if it fails to start (e.g., port in use). This error should be handled to prevent silent failures.
  3. Imports: It's a Go convention to group standard library imports. The log package is also needed for error handling.

Here's an updated version of the file that incorporates these changes. Please also update the code example in seenode/README.md to reflect these improvements.

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/gofiber/fiber/v2"
)

func main() {
	app := fiber.New()

	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Hello, Welcome to seenode 👋")
	})

	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

	if err := app.Listen(fmt.Sprintf(":%s", port)); err != nil {
		log.Fatalf("failed to start server: %v", err)
	}
}