@@ -48,77 +48,83 @@ MAX_FILE_SIZE=30
48
48
49
49
### Running
50
50
51
- - To create postgres container ` make postgres `
52
- - To create db ` make createdb `
53
- - To drop db ` make dropdb `
51
+ - To create the Postgres container - ` make postgres `
52
+ - To create the db - ` make createdb `
53
+ - To drop db - ` make dropdb `
54
54
55
- #### run ` go mod tidy ` to install packages
56
- #### cli commands
55
+ #### Run ` go mod tidy ` to install packages
56
+ #### CLI commands
57
57
```
58
58
go run main.go migrate_up
59
59
go run main.go dropdb
60
60
go run main.go migrate_steps --steps int
61
+ go run main.go generate_docs
61
62
go run main.go runserver --host localhost --port port (localhost, 5000 are default)
62
63
```
63
64
64
- #### to run migrations on the test database
65
+ #### To run migrations on the test database
65
66
```
66
67
go run main.go migrate_up -t
67
68
go run main.go dropdb -t
68
69
go run main.go migrate_steps -t --steps int
69
70
```
70
71
71
- ### Use the make file its your best friend 🛠
72
- #### Make commands
73
- ##### If you are on windows please use git bash or wsl also you would have to install make for windows
74
- ##### to install make for windows run ` winget install GnuWin32.Make `
72
+ ### Use the make file, its your best friend 🛠
73
+ #### Make commands -
74
+ If you are on windows please use Git Bash or WSL. You also have to install Make for Windows
75
+ To install Make for Windows run ` winget install GnuWin32.Make `
75
76
76
77
``` shell
77
- make postgres # creates docker container for postgres12
78
- # reads env variables from app.env
79
- make createdb # creates the db in the postgres container
80
- make dropdb # drops the db
81
- make migrate_up # migrates to the latest schema
82
- make sqlc_generate # generates sqlc code if you write queries
83
- make test # tests your code and shows coverage
84
- # its a big output make sure to read it all
78
+ make postgres # Creates docker container for postgres12
79
+ # Reads env variables from app.env
80
+ make createdb # Creates the db in the postgres container
81
+ make dropdb # Drops the db
82
+ make migrate_up # Migrates to the latest schema
83
+ make sqlc_generate # Generates sqlc code if you write queries
84
+ make generate_docs # Generates documentation
85
+ make test # Tests your code and shows coverage
86
+ # Its a big output make sure to read it all
85
87
```
86
88
87
89
## 🐳 Running with Docker
88
90
89
- Start the cdn ` docker-compose up `
91
+ Start the cdn with ` docker-compose up `
90
92
91
93
## 🗒️Docs
92
94
93
95
While adding new endpoints, you need add docs in the form of comments. For example:
94
96
``` go
95
-
96
97
/*
97
- Return Type : String
98
+ Response : String
98
99
99
100
URL Parameters: None
100
101
101
- Returns `Hello, World` when called.
102
+ Request Body:
103
+ - Name: username
104
+ - Type: String
105
+ - Description: "Username to register so and so . . ."
106
+
107
+ Description: "Returns `Hello, World` when called."
102
108
*/
103
109
func GetAllAssets (w http .ResponseWriter , r *http .Request ) {
104
110
w.WriteHeader (statusCode)
105
111
json.NewEncoder (w).Encode (" Hello, World" )
106
112
}
107
113
```
108
114
109
- And you will need to update the routes variable in [ main .go] ( /main .go )
115
+ And you will need to update the routes variable in [ routes .go] ( /api/routes .go )
110
116
111
117
## 🚨 Tests
112
- To test the cdn we can use two methods
118
+ There are two methods to test the cdn -
113
119
``` sh
114
120
make test
115
121
```
116
- If you don't have make installed
122
+ If you don't have make installed -
117
123
``` sh
118
124
go run main.go migrate_up -t
119
125
go test ./... -v
120
126
```
121
- ** When you contribute, you need to add tests on the features you add.**
127
+ ** When you contribute, you need to add tests for the features you add.**
122
128
123
129
## ⛏️ Built Using
124
130
@@ -127,4 +133,4 @@ go test ./... -v
127
133
- [ sqlc] ( https://github.com/kyleconroy/sqlc ) - Database Query Helper
128
134
129
135
## ✍️ Authors
130
- See the list of [ contributors] ( https://github.com/Tech-With-Tim/cdn/contributors ) who participated in this project.
136
+ See the list of [ contributors] ( https://github.com/Tech-With-Tim/cdn/contributors ) who participated in this project.
0 commit comments