|
| 1 | +# Scrappy Twitter API |
| 2 | +Scrappy Twitter API is a Go-backend project that is secured by the Magic SDK for Go. |
| 3 | + |
| 4 | +# Scrappy Twitter API (SERVER) |
| 5 | +This Go server is where all of the Scrappy Twitter API requests are handled. Once the user has generated an access token from the [client side](https://github.com/seemcat/scrappy-twitter-api-client), they can pass it into their Request Header as a Bearer token to hit protected endpoints. |
| 6 | + |
| 7 | +# API Routes |
| 8 | +- POST a tweet (protected): http://localhost:8080/tweet |
| 9 | +- GET all tweets (unprotected): http://localhost:8080/tweets |
| 10 | +- GET a single tweet (unprotected): http://localhost:8080/tweets/1 |
| 11 | +- DELETE a tweet (protected): http://localhost:8080/tweets/2 |
| 12 | + |
| 13 | +# Noteworthy Packages |
| 14 | +- [gorilla/handlers](https://github.com/gorilla/handlers): Lets us enable CORS. |
| 15 | +- [gorilla/mux](https://github.com/gorilla/mux): Lets us build a powerful HTTP router and URL matcher. |
| 16 | +- [magic-admin-go/client](https://docs.magic.link/admin-sdk/go/get-started#creating-an-sdk-client-instance): Lets us instantiate the Magic SDK for Go. |
| 17 | +- [magic-admin-go/token](https://docs.magic.link/admin-sdk/go/get-started#creating-a-token-instance): Lets us create a Token instance. |
| 18 | + |
| 19 | +# Quickstart |
| 20 | +## Magic Setup |
| 21 | +1. Sign up for an account on [Magic](https://magic.link/). |
| 22 | +2. Create an app. |
| 23 | +3. Copy your app's Test Secret Key (you'll need it soon). |
| 24 | + |
| 25 | +## Server Setup |
| 26 | +1. `git clone https://github.com/seemcat/scrappy-twitter-api-server.git` |
| 27 | +2. `cd scrappy-twitter-api-server` |
| 28 | +3. `mv .env.example .env` |
| 29 | + Paste the Test Secret Key you just copied as the value for `MAGIC_TEST_SECRET_KEY` in .env: |
| 30 | + ``` |
| 31 | + MAGIC_TEST_SECRET_KEY=sk_test_XXXXXXXXXX |
| 32 | + ``` |
| 33 | +4. Run all .go files with `go run .` |
| 34 | +
|
| 35 | +## Test with Postman |
| 36 | +1. Import the DEV version of the Scrappy Twitter API Postman Collection: |
| 37 | + [](https://god.postman.co/run-collection/13995d5adf65c3ca5c88) |
| 38 | +2. Generate an access token on the Client side. (Click [here](https://github.com/seemcat/scrappy-twitter-api-client) to set up and run the client side.) |
| 39 | +3. Pass the access token as a Bearer token into the Postman Collection’s HTTP Authorization request header. |
| 40 | +4. Send your requests to the Scrappy Twitter API! 🎉 |
0 commit comments