https://github.com/caasmo/restinpieces-js-sdk-example
https://github.com/caasmo/restinpieces-js-sdk-example
Last synced: about 21 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/caasmo/restinpieces-js-sdk-example
- Owner: caasmo
- Created: 2026-04-15T15:32:53.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2026-04-18T20:27:50.000Z (2 months ago)
- Last Synced: 2026-04-18T22:25:19.253Z (2 months ago)
- Language: JavaScript
- Size: 119 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RestInPieces JS SDK Example
This project serves as a comprehensive example of how to integrate the RestInPieces JS SDK within a Go-based web application. It demonstrates a typical project structure that bundles a frontend with a Go backend into a single, self-contained binary.
## Standard Layout
This project follows a standard Go and frontend integration layout, designed to produce a self-contained binary.
### Frontend (`/web`)
The `web/` directory contains the complete frontend environment:
- **`src/`**: Source files including HTML, CSS, JavaScript, and React components.
- **`dist/`**: Compiled, minified, and gzipped production assets.
- **`package.json` & `vite.config.js`**: Frontend dependency management and bundling.
- **`embed.go`**: Defines the `web` Go package and uses `//go:embed dist` to include the compiled assets in the binary via the `Assets` variable.
### Backend
- **Root Directory**: The core Go application logic resides in the root of the project.
- **Entry Point (`/cmd`)**: The application entry point is located in `cmd/example/main.go`.
- **Asset Integration**: The backend serves the bundled frontend by sub-mounting the `dist` directory from the embedded filesystem:
```go
subFS, err := fs.Sub(web.Assets, "dist")
```
## Asset Generation
To bundle and optimize frontend assets (HTML, CSS, JavaScript) with minification and gzip compression:
go generate ./web/
This creates production-ready assets in `web/dist/` with both compressed (.gz) and uncompressed versions.
### Custom Builder
While modern frontend projects typically rely on external build tools like Vite or Webpack, this repository demonstrates a **custom builder** approach.
The build logic is implemented in Go using the [esbuild](https://github.com/evanw/esbuild) library, located at `gen/gogenerate-assets.go`.
## Run
go run cmd/example/main.go -age-key age_key.txt -dbpath app.db
## TODO
- login otp
- signup otp
- otp workflows