Tech With Tim - CDN
CDN for the Tech With Tim website using Go
๐
Table of Contents
-
๐ Getting Started -
๐ณ Running with Docker -
๐จ Tests -
๐ Licence -
โ๏ธ Built Using -
โ๏ธ Authors
๐
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See Running with Docker if you want to setup the CDN faster with Docker. ( Docker is optional )
Environment variables
Set the environment variables. Start by writing this in a file named app.env
and test.env
: (test.env is required for running tests)
app.env and test.env should look like this:
DB_URI=postgres://user:password@localhost:5432/dbname?sslmode=disable
SECRET_KEY=secret
MAX_FILE_SIZE=30
SECRET_KEY
is the key used for the JWT token encoding.MAX_FILE_SIZE
is the maxiumum file size allowed in asset upload (in mb)
Running
- To create postgres container
make postgres
- To create db
make createdb
- To drop db
make dropdb
go mod tidy
to install packages
run cli commands
go run main.go migrate_up
go run main.go dropdb
go run main.go migrate_steps --steps int
go run main.go runserver --host localhost --port port (localhost, 5000 are default)
to run migrations on the test database
go run main.go migrate_up -t
go run main.go dropdb -t
go run main.go migrate_steps -t --steps int
๐
Use the make file its your best friend Make commands
If you are on windows please use git bash or wsl also you would have to install make for windows
winget install GnuWin32.Make
to install make for windows run make postgres #creates docker container for postgres12
# reads env variables from app.env
make createdb #creates the db in the postgres container
make dropdb #drops the db
make migrate_up #migrates to the latest schema
make sqlc_generate #generates sqlc code if you write queries
make test # tests your code and shows coverage
#its a big output make sure to read it all
๐ณ
Running with Docker
Start the cdn docker-compose up
๐จ
Tests
To test the cdn we can use two methods
make test
If you don't have make installed
go run main.go migrate_up -t
go test ./... -v
When you contribute, you need to add tests on the features you add.
โ๏ธ
Built Using
โ๏ธ
Authors
See the list of contributors who participated in this project.