All Projects → sno6 → gosane

sno6 / gosane

Licence: other
A sane and simple Go REST API template.

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to gosane

food-help
A clone of popular food and business review web app yelp
Stars: ✭ 24 (-70.37%)
Mutual labels:  backend, production
enterprise-applications-patterns
Collection of enterprise application patterns
Stars: ✭ 17 (-79.01%)
Mutual labels:  backend
laravel-conditional-providers
THIS PACKAGE HAS BEEN DEPRECATED — Load Laravel service providers and facades based on the current environment.
Stars: ✭ 26 (-67.9%)
Mutual labels:  production
andresrodriguez55.github.io
Personal blog and portfolio with administration panel, notification system and comment system.
Stars: ✭ 18 (-77.78%)
Mutual labels:  backend
scaling-nodejs
📈 Scaling Node.js on each X, Y and Z axis using Node.js Native Modules, PM2, AWS , Load Balancers, AutoScaling, Nginx, AWS Cloudfront
Stars: ✭ 73 (-9.88%)
Mutual labels:  backend
ConfTalks
⚠️ Development is currently on hold 🎥 An open source index of already recorded and scheduled conference talks to help you decide if you should go. Built for all developers 👩‍💻👨‍💻
Stars: ✭ 53 (-34.57%)
Mutual labels:  backend
inspect
Source Code that Powers the CSGOFloat Inspect Link API
Stars: ✭ 220 (+171.6%)
Mutual labels:  backend
Django-on-Docker-with-Heroku-and-OpenCV
Deploy Django on Docker to Heroku and include OpenCV
Stars: ✭ 24 (-70.37%)
Mutual labels:  production
UPES-SPE-Fest
An Instagram like Social Networking Android App for UPES SPE Fest using Firebase as backend.
Stars: ✭ 39 (-51.85%)
Mutual labels:  backend
flaskbooks
A very light social network & RESTful API for sharing books using flask!
Stars: ✭ 19 (-76.54%)
Mutual labels:  backend
newrelic-sidekiq-metrics
Implements recording Sidekiq stats (like queue or retry size) to New Relic metrics
Stars: ✭ 15 (-81.48%)
Mutual labels:  backend
reactnative-android-production
Step by step guid for compiling and installing React Native Android app [ bundled release version ] to your test device.
Stars: ✭ 51 (-37.04%)
Mutual labels:  production
roll
Roll — backend for Clojure
Stars: ✭ 73 (-9.88%)
Mutual labels:  backend
Events-based-organizational-website
The official codebase for college-based (event managing) organizations. FOUR-LEVEL Authorization system and scalable.
Stars: ✭ 14 (-82.72%)
Mutual labels:  backend
flame
Ruby web-framework
Stars: ✭ 43 (-46.91%)
Mutual labels:  backend
restrictfe
TYPO3 extension restrictfe. Blocks access to frontend and allows to show it only to some defined exception's like if the request is from an authorized backend user, has specific IP, header etc.
Stars: ✭ 12 (-85.19%)
Mutual labels:  production
lego
LEGO Backend
Stars: ✭ 48 (-40.74%)
Mutual labels:  backend
aionic-core
The core API required for all other Aionic applications
Stars: ✭ 106 (+30.86%)
Mutual labels:  backend
Magento2-Admin-Module-Sample
Minimal code to create an admin/backend module in Magento2
Stars: ✭ 45 (-44.44%)
Mutual labels:  backend
Authl
A library for managing federated identity
Stars: ✭ 20 (-75.31%)
Mutual labels:  backend

Gosane 🧘‍♀️

License: MIT

A sane and simple Go REST API template. Clone me and edit me to fit your usecase.

What is Gosane?

Gosane is a cloneable API template to get you up and running quickly. It has made a lot of decisions for you, but easily allows you to swap out the things you don't like.

Features

Service Description
Auth 🔑 Social (FB / Google) as well as email based JWT authentication.
Database 💽 Database support using the amazing https://github.com/ent/ent package.
Email ✉️ There's an example AWS SES implementation and an easily extendable interface.
Config 🗃 Simple JSON and environment based configuration via https://github.com/sno6/config.
Monitoring 🕵️ Prometheus handlers for monitoring.
Errors 🔦 Automatic sentry error logging via: https://sentry.io
Validation 👮‍♀️ Validation using an extended version of the https://github.com/go-playground/validator package.
Build / Test 💪 Automatically build and test your code with built in Github pipelines.
Server 💻 The underlying server framework is Gin, so you benefit from all the goodness you can find over at: https://github.com/gin-gonic/gin

Structure

Browse the codebase in VS Code here: https://github1s.com/sno6/gosane

Gosane is structured as follows:

Handlers

Each handler (or endpoint) is grouped and encapsulated in its own folder as can be seen here. Firstly, you must define the relative path for the handler group in a file such as this, and then define each endpoint as a separate handler.

Services & Stores

A handler interacts with your business logic through services, which are aptly defined in /service. These services interact with your database entities (using ent) via stores. The flow of information should look something like the following:

Handler <-> Services <-> Stores

A store should never be used directly in a handler, and a service should never be used in a store.

Internal

Anything that isn't considered business logic should live here. Typically you want to structure these as small modules that you could rip out and run isolated from the rest of the project, if you had to. Examples include, email, database, sentry (error management), etc.

Dependencies

Gosane follows a simple dependency injection plan. All dependencies for your API are defined in api/register.go. The server initialises all dependencies and passes them through to the handlers via the Register method.

That's about it, the rest is up to you.

How to use Gosane

1. Clone the project

git clone [email protected]:sno6/gosane.git

2. Run the damn thing

./run.sh

Note that if the above command errors you may need to give the script executive permissions by running: chmod +x ./run.sh

Postman

You can download the exported Postman collection here.

Potential issues

Gosane is complaining about a Sentry DSN, what's that?

In order for Sentry to know where to log errors to it needs a URL. To get one, follow these steps:

  1. Sign up for a free account over at https://sentry.io/welcome
  2. Select Go as the platform.
  3. Copy the Dsn value in the sample code to your .env file.

That's it.

But what if I don't want social OAuth?

Just simply rip out everything for social OAuth. Here's where everything will be:

  1. /api/handler/oauth This whole folder can go.
  2. /api/register.go Remove the reference to the OAuth handler here.
  3. /config/config.go Remove everything to do with OAuth from the config.
  4. /internal/server.go Remove the fb/google configs that are passed to the API as dependencies.

But what if I don't want Sentry?

Similarly, do the following:

  1. /internal/sentry This whole folder can go.
  2. /config/config.go Remove all Sentry related config params.
  3. /api/register.go Remove the reference to Sentry from the dependencies list here.
  4. /internal/server.go Remove the Sentry dependency and deferred handler from here.

For any other problems feel free to create an issue and ping me @sno6.

Future work (to be completed in the near future)

  • ~80-100% testing coverage.
  • Add missing auth related endpoints: "forgot password", "re-send verification email".
  • Handle database migrations.
  • Transaction rollbacks on recovery state.
  • Command line tool to generate new project based on feature requirements.
  • Add an example handler to show pagination & sorting usage.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].