Skip to content

midasbytes/svelte-app-typescript-go

Repository files navigation

A Svelte Demo Web App with Golang Backend Service and SQLite

This is a simple shopping demo app, inspired by the same Angular/React/Vue.js examples in Essential Typescript by Adam Freeman.

  • The frontend is built with Svelte and SvelteKit with TypeScript typing. I use @sveltejs/adapter-static to generate a static JavaScript production.
  • The backend is built with Golang: a server/REST APIs using gin and go-sqlite3 for the SQlite3 database.
  • A Dockerfile tha uses multi-stage builds (image size ~24 MB). The Dockerfile will update everything to the latest version.

Right now, like all the original examples, the app only reads product lists and write order data.

ezgif-5-22d3d39425

Project Local Setup

For local environment, you need

npm run setup

Install Svelte and Golang app dependencies.

npm i
npm prune
go get -u ./...

npm run upgrade-all

Upgrade all NPM packages using npm-check-updates:

npx npm-check-updates -u
npm install
npm prune

npm run build-all

Build Svelte production and Golang executable binary.

npm run build
go build .

npm run serve

Start a server at http://localhost:8080.

./main

You can change the host and port as

./main -host 127.0.0.1 -port 8080

npm start

Run all the scripts above.

Generate and Run in Docker

npm run docker

Generate a Docker image then run it.

docker build . -t svelte-ts-go -f Dockerfile
docker run -p 8080:8080 --rm svelte-ts-go

(Git Commands Notes for Self)

git clone https://github.com/alankrantas/svelteapp-typescript-go.git
git pull origin master
git add .
git commit -m "Updating"
git remote add origin https://github.com/alankrantas/svelteapp-typescript-go.git
git push origin master

After that, simply run npm run commit to commit changes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published