You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.8 KiB
Markdown

2 years ago
# Go Vite Kit
Minimal boilerplate project for a Golang server using [Fiber](https://github.com/gofiber/fiber) and [ViteJS](https://github.com/vitejs/vite) for static pages
2 years ago
## Features
- ⚡️ [Go Fiber](https://github.com/gofiber/fiber)
- 📦 [ViteJS](http://vitejs.dev/)
- 🎨 [Sass](https://sass-lang.com/)
- 🗄️ [Sqlite3](https://github.com/mattn/go-sqlite3)
## Architecture
- `frontend/`
2 years ago
This is a Vite project for building all the static pages used by this app.
- `backend/`
This keeps all server related files
2 years ago
- `config/`
2 years ago
Loads env variables and keeps them as globals
2 years ago
- `database/`
Module with a `Database` interface and two implementation: `memDB` is an in-memory database for testing purposes. `sqliteDB` is a wrapper for working with an SQLite database.
- `routes/`
Various functions for configuring all the server routes.
A very important file is `backend/routes/router.go` that contains the `HtmlEntrypoints` variable that is used both by the backend and ViteJS to mount HTML entrypoints.
When building the frontend ViteJS will call `go run ./cmd/routes` to read the content of this variabile. This is also used while developing to let Vite know add all necessary entrypoints to the dev server.
2 years ago
## Usage
To setup the project first install the required npm packages
2 years ago
```bash
$ npm install
2 years ago
```
then you can start versioning the **lock file** of your package manager.
2 years ago
### Development
```bash
# Development
$ MODE=dev go run -v ./cmd/server
2 years ago
# Development with watcher
$ fd -e go | MODE=dev entr -r go run -v ./cmd/server
2 years ago
```
### Production
You can build everything with the following command, it will build first the frontend and then the backend and generate `./out/server`.
2 years ago
```bash
# Build
$ go run -v ./cmd/build
2 years ago
# Run
$ ./out/server
2 years ago
```