|
|
3 years ago | |
|---|---|---|
| backend | 3 years ago | |
| cmd/server | 3 years ago | |
| frontend | 3 years ago | |
| meta | 3 years ago | |
| .env.default | 3 years ago | |
| .gitignore | 3 years ago | |
| README.md | 3 years ago | |
| go.mod | 3 years ago | |
| go.sum | 3 years ago | |
| package.json | 3 years ago | |
| pnpm-lock.yaml | 3 years ago | |
| vite.config.js | 3 years ago | |
README.md
Go Vite Kit
Minimal boilerplate project for a Golang server using Fiber and ViteJS for static pages
Features
Architecture
-
frontend/This is a Vite project for building all the static pages used by this app.
-
backend/This keeps all server related files
-
config/Loads env variables and keeps them as globals
-
database/Module with a
Databaseinterface and two implementation:memDBis an in-memory database for testing purposes.sqliteDBis 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.gothat contains theHtmlEntrypointsvariable that is used both by the backend and ViteJS to mount HTML entrypoints.When building the frontend ViteJS will call
go run ./meta/routesto read the content of theHtmlEntrypointsvariable. This is also used while developing to let Vite know add all necessary entrypoints to the dev server.
-
Usage
To setup the project first install the required npm packages
# Install all JS dependencies
$ npm install
then you can start versioning the lock file of your package manager.
Development
# Development
$ MODE=dev go run -v ./cmd/server
# Development with watcher
$ fd -e go | MODE=dev entr -r go run -v ./cmd/server
Production
You can build everything with the following command, it will build first the frontend and then the backend and generate ./out/server.
# Build
$ go run -v ./cmd/build
# Run
$ ./out/server