Skip to content

carlynorama/APIng

Repository files navigation

APIng

Testing for

References

Testing Calls

Making Tiny Test Images

  • brew install imagemagick if necessary
  • convert original.png -resize 10x10^ -gravity center -extent 5x5 new.png
  • e.g. convert small_test.png -resize 10x10^ -gravity center -extent 5x5 very_small_test.png

Using NetCat

    ```zsh
    # Start up netcat on port 8080 
    nc -l -p 8080 
    # if that does not work try, but that means calls will only resolve at http://localhost:8080
    nc -l localhost 8080  
    # or 
    brew install netcat
    netcat -l -p 8080
    # live dangerously if you get sick of restarting it
    # You might have to ^C a few times to catch it during a sleep
    while [ 1 ] ; do ; netcat -l -p 8080 ; sleep 1 ; done
    ```

Go to http://localhost:8080 and see the call show up there, run commands from here, etc. NetCat does not respond so make sure to include timeouts.

Checking Parsing

Does it parse? Service that will reply with json about what it thinks it got back semantically, rather than just a reflection.

cURL Examples To Crib From

cURL commands sent to BOTH NetCat and httpbin can be very instructive on what your code should be doing.

  • curl -s -X POST 'https://httpbin.org/post' --form foo="bar" --form file="@very_small_test.png" will let you see the form data as sent.
  • curl -s -X POST http://localhost:8080 --form foo="bar" --form file="@very_small_test.png" will let you see how a server will typically parse it. Note that the image is parsed as an attachment NOT form data.

New Project SetUp

    ```zsh
    mkdir APIng
    cd APIng
    git init
    git branch -M main
    touch README.md
    swift package init --type executable
    touch .gitattributes
    touch .env
    swift run
    git add .
    git commit -m "hello project"
    # Options for making a remote:
    # https://cli.github.com/manual/gh_repo_create  (brew install gh)
    #gh repo create [<name>] --public
    #git remote add origin [repo-url]  #<- links an existing repo to git
    #git remote -v #checks to see if it worked
    #Potential GOTCHAs - https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey#make-sure-you-have-a-key-that-is-being-used
    git push -u origin main
    ```

.gitignore

# ------ generated by package init.
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

## ----------- added

# VSCode
.vscode

# Secrets & Environment
.env

# Swift additional
Package.resolved

# Python
__pycache__/
*.py[cod]
*$py.class

.gitattributes

# Auto detect text files and perform LF normalization
* text=auto

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages