Giter VIP home page Giter VIP logo

cdn's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.