Skip to content

cesarvspr/api-go

Repository files navigation

Quick backend using Fiber.

Fiber is an Express.js inspired web framework build on top of Fasthttp, the fastest HTTP engine for Go. Designed to ease things up for fast development with zero memory allocation and performance in mind.

⚡️ Quick start

Run project by this command:

Use vscode launcher and play with Launch local

you may need to place an api-key on the env of launch.json file.

😉 Testing

Minor tests are present. For testing run go test inside routes folder.

📦 Used packages

Name Version Type
gofiber/fiber v2.34.0 core
arsmn/fiber-swagger v2.31.1 middleware
stretchr/testify v1.7.1 tests
joho/godotenv v1.4.0 config
IBM/cloudant-go-sdk v0.2.1 database
swaggo/swag v1.8.2 utils
google/uuid v1.3.0 utils
go-playground/validator v10.10.0 utils

Go to API Docs page (Swagger): 127.0.0.1:4555/swagger/index.html

./app

Folder with business logic only. This directory doesn't care about what database driver you're using or which caching solution your choose or any third-party things.

  • ./app/controllers folder for functional controllers (used in routes)
  • ./app/models folder for describe business models and methods of your project
  • ./app/queries folder for describe queries for models of your project

./docs

Folder with API Documentation. This directory contains config files for auto-generated API Docs by Swagger.

./pkg

Folder with project-specific functionality. This directory contains all the project-specific code tailored only for your business use case, like configs, middleware, routes or utils.

  • ./pkg/configs folder for configuration functions
  • ./pkg/middleware folder for add middleware (Fiber built-in and yours)
  • ./pkg/repository folder for describe const of your project
  • ./pkg/routes folder for describe routes of your project
  • ./pkg/utils folder with utility functions (server starter, error checker, etc)

./platform

Folder with platform-level logic. This directory contains all the platform-level logic that will build up the actual project, like setting up the database or cache server instance and storing migrations.

  • ./platform/database folder with database setup functions (by default, Cloudant)

⚙️ Configuration

#

# Stage status to start server:
#   - "dev", for start server without graceful shutdown
#   - "prod", for start server with graceful shutdown
STAGE_STATUS="dev"

# Server settings:
SERVER_HOST="0.0.0.0"
SERVER_PORT=5000
SERVER_READ_TIMEOUT=60

# AUTH settings:
API-KEY=2a855350-40b2-4598-b937-3ad5824f8ac4

# Database settings:
CLOUDANT_APIKEY=#create your db (or request to use mine?)
CLOUDANT_URL=https://a273a6f7-77f4-43eb-88ef-58fb17fbeca0-bluemix.cloudantnosqldb.appdomain.cloud

About

Small but useful straight forward Go api

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published