CDN for the Tech With Tim website using Go
- ๐ Getting Started
- ๐ณ Running with Docker
- ๐จ Tests
- ๐ Licence
- โ๏ธ Built Using
- โ๏ธ Authors
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 )
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:
POSTGRES_USER=user
POSTGRES_PASSWORD=pwd
DB_NAME=db
DB_HOST=localhost
DB_PORT=5432
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)
- To create postgres container
make postgres
- To create db
make createdb
- To drop db
make dropdb
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)
go run main.go migrate_up -t
go run main.go dropdb -t
go run main.go migrate_steps -t --steps int
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
Start the cdn docker-compose up
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.
See the list of contributors who participated in this project.