You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Felix Soederhuyzen e81d7dd4e9 added attribution to getIPAddress code 9 months ago
.docker init 9 months ago
.gitignore init 9 months ago
Makefile working exercise 9 months ago
README.md working exercise 9 months ago
docker-compose.yml added docu for exercise tracker 9 months ago
handler_exercise.go working exercise 9 months ago
handler_fileanalyse.go working fileanalyse 9 months ago
handler_shorturl.go fixed tls bug 9 months ago
handler_timestamp.go working shorturl 9 months ago
handler_types.go working exercise 9 months ago
handler_whoami.go added attribution to getIPAddress code 9 months ago
logger.go init 9 months ago
main.go fix port chooser bug 9 months ago
router.go init 9 months ago
routes.go working exercise 9 months ago

README.md

freecodecamp

Profile Completed projects accessible at https://freecodecamp.varelus.com

Index

Usage

Either

docker

Requirements:

  • docker
  • docker-compose

Edit/create docker-compose.yml:

version: "3.7"

networks:
  freecodecamp:
    external: false

services:
  freecodecamp:
    build:
      context: .
      dockerfile: .docker/Dockerfile
    restart: always
    networks:
      - freecodecamp
$ docker-compose up -d --build

Server will bind to http://freecodecamp

run

$ make dep
$ make server
$ ./server

or

$ go run .

Server will bind to 0.0.0.0:8080

Apis And Microservices Certification (300 hours)

Timestamp Microservice

GET /api/timestamp

Example Response:
{"unix":1560613060480,"utc":"Sat Jun 15 15:37:40 UTC 2019"}

date is date.Now()

Error Response:
{"error":"Invalid Date"}

GET /api/timestamp/:date_string?

Example Response:
{"unix":1560613060480,"utc":"Sat Jun 15 15:37:40 UTC 2019"}

date is date_string parsed with Date()

Error Response:
{"error":"Invalid Date"}

Request Header Parser Microservice

GET /api/whoami

Example Response:
{"ipaddress":"159.20.14.100","language":"en-US,en;q=0.5",
"software":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"}

URL Shortener Microservice

POST /api/shorturl/new

Example Body:
url=https%3A%2F%2Fwww.google.de
Example Response:
{"original_url":"www.google.com","short_url":1}
Error Response:
{"error":"invalid URL"}

GET /api/shorturl/:short_url

Example Response:
REDIRECT www.google.com

Exercise Tracker

POST /api/exercise/new-user

Example Body:
username=test
Error Response:
username already taken
Example Response:
{"username":"test","_id":"HkzTLAMyB"}

POST /api/exercise/add

Example Body:
userId=HkzTLAMyB&description=lol&duration=12&date=
Error Response:
unknown _id
Path `duration` is required.
Path `description` is required.
Example Response:
{
  "username": "test",
  "description": "lol",
  "duration": 12,
  "_id": "HkzTLAMyB",
  "date": "Sat Jun 15 2019"
}

GET /api/exercise/log?{userId}[&from][&to][&limit]

{ } = required, [ ] = optional
from, to = dates (yyyy-mm-dd); limit = number

Error Response:
unknown _id
Example Response:
{
  "_id": "HkzTLAMyB",
  "username": "test",
  "count": 1,
  "log": [
    {
      "description": "lol",
      "duration": 12,
      "date": "Sat Jun 15 2019"
    }
  ]
}

File Metadata Microservice

POST /api/fileanalyse

Example Headers:
Content-Type: multipart/form-data; boundary=X-SOMETHING-BOUNDARY
Example Form data:
--X-SOMETHING-BOUNDARY
Content-Disposition: form-data; name="upfile"; filename="README.md"
Content-Type: text/markdown
# freecodecamp curriculum
<snip>
--X-SOMETHING-BOUNDARY--
Example Response
{
  "name": "README.md",
  "type": "text/markdown",
  "size": 2149
}