Skip to content

Commit

Permalink
refactor(*): use 2000 as default port
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Mar 30, 2021
1 parent b83105a commit 9703bd3
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Application port (for both inside and outside docker)
# You can browse locally to http://localhost:<APP_PORT>
PORT=1000
# You can browse locally to http://localhost:<PORT>
PORT=2000

# Application env:
# Options: dev, prod, test
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cp .example.env .env
docker-compose up
```

After a few seconds, you should be able to browse to [localhost:1000](http://localhost:1000).
After a few seconds, you should be able to browse to [localhost:2000](http://localhost:2000).

## Testing

Expand Down Expand Up @@ -119,7 +119,7 @@ Creates a new short code for given URL.
{
"status": 200,
"short_code": "qaFxz",
"short_url": "http://localhost:1000/qaFxz"
"short_url": "http://localhost:2000/qaFxz"
}
```

Expand Down
2 changes: 1 addition & 1 deletion controller/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestListURL(t *testing.T) {
rand.Seed(time.Now().UTC().UnixNano())

_ = os.Setenv("APP_ALLOW_DUPE_URL", "1")
url := fmt.Sprintf("http://localhost:1000/very/long/url-%v", rand.Intn(1000000))
url := fmt.Sprintf("http://localhost:2000/very/long/url-%v", rand.Intn(1000000))
body := TestBody{"url": url, "expires_on": "2030-01-01 00:00:00", "keywords": []string{"local"}}
resp := request("POST", "/api/urls", body, CreateShortURL)

Expand Down
2 changes: 1 addition & 1 deletion controller/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestCreateShortURL(t *testing.T) {

t.Run("create short url - OK", func(t *testing.T) {
tester := func(status int, message string) {
body := TestBody{"url": "http://localhost:1000/very/long/url", "expires_on": "2030-01-01 00:00:00"}
body := TestBody{"url": "http://localhost:2000/very/long/url", "expires_on": "2030-01-01 00:00:00"}
resp := request("POST", "/api/urls", body, CreateShortURL)

resp.assertStatus(status, t)
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ services:
urlsh:
image: golang:1.14
working_dir: /go/src/app
command: sh -c 'sleep 5 && go run main.go'
command: sh -c 'sleep 2 && go run main.go'
ports:
- ${APP_PORT:-1000}:${APP_PORT:-1000}
- ${PORT:-2000}:${PORT:-2000}
volumes:
- .:/go/src/app:delegated
env_file:
Expand All @@ -21,7 +21,7 @@ services:
urlshdb:
image: postgres:12.4
ports:
- 2000:5432
- 2001:5432
volumes:
- dbdata:/var/lib/postgresql
- ./init-test-db.sh:/docker-entrypoint-initdb.d/init-test-db.sh
Expand All @@ -33,7 +33,7 @@ services:
urlshcache:
image: redis:alpine
ports:
- 3000:6379
- 2002:6379
volumes:
- cachedata:/data

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func getPort() string {
return port
}

return "1000"
return "2000"
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion postman/urlsh.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"urls"
]
},
"description": "# POST /api/urls\n\nCreates a new short code for given URL.\n\n## Request example\n\n```json\n{\n \"url\": \"http://somedomain.com/some/very/long/url\",\n \"expires_on\": \"\",\n \"keywords\": [\"key\", \"word\"]\n}\n```\n\n## Response example\n\n```json\n{\n \"status\": 200,\n \"short_code\": \"qaFxz\",\n \"short_url\": \"http://localhost:1000/qaFxz\"\n}\n```\n"
"description": "# POST /api/urls\n\nCreates a new short code for given URL.\n\n## Request example\n\n```json\n{\n \"url\": \"http://somedomain.com/some/very/long/url\",\n \"expires_on\": \"\",\n \"keywords\": [\"key\", \"word\"]\n}\n```\n\n## Response example\n\n```json\n{\n \"status\": 200,\n \"short_code\": \"qaFxz\",\n \"short_url\": \"http://localhost:2000/qaFxz\"\n}\n```\n"
},
"response": []
},
Expand Down
2 changes: 1 addition & 1 deletion postman/urlsh.postman_environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"values": [
{
"key": "baseUrl",
"value": "http://localhost:1000",
"value": "http://localhost:2000",
"enabled": true
},
{
Expand Down

0 comments on commit 9703bd3

Please sign in to comment.