Giter Club home page Giter Club logo

chive's Introduction

chive

Status

I have refactored this project to use vuetify and it looks pretty now!

Screenshot


A website starter with Go using the Chi router, MongoDB, and Vue for the client. This project compiles into one single binary that can be executed on whatever OS or architecture you build it for.

Architecture

A key difference between this and other full stack projects is that I am not including server-side rendering. Instead, I am using templating on the server side to produce a unique HTML header for each path, then letting the javascript client load as per normal.

So if someone goes to http://website/ and then clicks on example 1234, they will simply make an API request to the server to fecth 1234. The server will respond with JSON data as you'd expect. However, if someone browses directly to http://website/examples/1234, the server will respond with the HTML inserted into the header that generates meta tags with pertinent information about the asset, and then the javascript app loads as usual and the vue-router loads up example 1234.

I think that this approach is a little better than SSR for PWAs because it provides the SSO and the "crawlability" that SSR gives you, but it's a lot easier. And since the service worker is keeping all the static assets on the device anyway, you don't have to worry about load times on subsequent visits to your site by actual people.

Instructions

Development

Unfortunately, right now you need two terminals open:

  • Run the client by changing to the client directory and executing "npm run dev"
  • Run the server by running "go run *.go" from the project root
Production

Make sure to do things in this order. The fully built client will be incorported into the binary file.

  • Build the client by changing to the client directory and executing "npm run build"
  • In the project root directory, execute:
rice embed-go
go build

PS - make sure to set your GOOS and GOARCH environment variables accordingly for the target server

Lastly, you can serve this site over TLS and http2 (including push) by setting up a caddy server and reverse-proxying to your app. Caddy does it all for you magically. https://caddyserver.com

Here's an example caddyfile:

yourwebsite.com www.yourwebsite.com {
  tls [email protected]
  push
  proxy / http://localhost:6000
  log yourwebsite.access.log
}

chive's People

Contributors

tutley avatar

Watchers

 avatar

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.