SnowballSH / cdn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project logo

Tech With Tim - CDN

Status
codecov Lint & Test GitHub Issues GitHub Pull Requests Licence Discord

CDN for the Tech With Tim website using Go

πŸ“ Table of Contents

🏁 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:

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)

Running

  • To create postgres container make postgres
  • To create db make createdb
  • To drop db make dropdb

run go mod tidy to install packages

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
to install make for windows run winget install GnuWin32.Make
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

  • Go - Language
  • go-chi - Router
  • sqlc - Database Query Helper

✍️ Authors

See the list of contributors who participated in this project.

About

License:MIT License


Languages

Language:Go 96.1%Language:Makefile 3.4%Language:Dockerfile 0.5%