Coder Social home page Coder Social logo

connect-gin's Introduction

Connect-gin (obsolete)

The backend web server for Connect. Built using Gin, Golang-JWT (and lib/pq as the database driver to connect to Postgres (Supabase)).

Why did you abandon this project?

I really wanted to build something cool with Go (I was really intrigued by the language and its famed "speed"... and also the name Go sounds really cool :P). However, I decided to switch to express.js partway through:

  1. I'm an absolute newbie when it comes to Go so I may be wrong here, but from what I've observed, the packages built for Go don't seem to be as mature as the ones built for Node.

    I really had to go digging to find something as simple (at least in case of Node) as a web socket library. (I still wanted to stick to Go and decided to switch over to express.js and socket.io to build the signalling server and continue with Gin for the rest of the backend (commit history for the connect-express repo shows these changes), but, as you can see, I eventually abandoned the project altogether, because...).

  2. So Gin apparently doesn't serve the static build files of a React (CRA) project the right way?

    The way express handles this is pretty straightforward: you point to the server the directory that contains the static files, and then serve the index.html file on one of the routes and the scripts linked in it take over. The key point here is that the above approach takes care of the client side routing (at least when built using react-router).

    This isn't the case with Gin, which completely breaks the frontend routing unless the user begins from the base route. Something like gin-contrib/static didn't help either (assuming it should have; or maybe I used it incorrectly). The only way to get this to work at this point was to manually serve the the individual HTML files for every route (which is just as tedious as it sounds).

The app is still fully-functional... ish

And so, there ended my 'Connect' journey with Gin. However, this project is still "fully-functional" though -- just set up a signalling server and link the react-app with this server for the basic routes (auth, etc.), and to the signalling server for websocket communication -- boom, you're 'CONNECT'-ed (pun intended).

You may also want to find a way to fix the main issue which forced me to give up on Gin and this project -- serving react's build files without having the client side routing completely break down (just use express? wink wink or run it in development mode forever because who cares about performance).

Still like Go, but will probably stick to Node for now.

Installing

  1. Clone the repo

  2. Install all the dependencies using go get ..

  3. Create a .env file in the root directory and add the following environment variables: DB_PASSWORD, DB_HOST_URL, DB_PORT. See the models folder for the database schemas when setting up your own database.

  4. Run the server using go run main.go.

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.