|
10 | 10 |
|
11 | 11 | 
|
12 | 12 |
|
| 13 | +## Running Locally |
| 14 | + |
| 15 | +1. Install the project |
| 16 | +```sh |
| 17 | +npm i |
| 18 | +``` |
| 19 | + |
| 20 | +2. CloudFlare Authentication |
| 21 | +```sh |
| 22 | +npx wrangler login |
| 23 | +``` |
| 24 | + |
| 25 | +3. Get Your Account Id |
| 26 | +```sh |
| 27 | +npx wrangler whoami |
| 28 | +``` |
| 29 | + |
| 30 | +4. Add your configs to `wrangler.toml` |
| 31 | +```sh |
| 32 | +[env.YOUR_USERNAME] |
| 33 | +workers_dev = true |
| 34 | +account_id = "YOUR_ACCOUNT_ID" |
| 35 | +r2_buckets = [ |
| 36 | + { binding = "CARPARK", bucket_name = "carpark-YOUR_USERNAME-0", preview_bucket_name = "carpark-YOUR_USERNAME-preview-0" } |
| 37 | +] |
| 38 | + |
| 39 | +[env.YOUR_USERNAME.vars] |
| 40 | +DEBUG = "true" |
| 41 | +FF_RATE_LIMITER_ENABLED = "false" |
| 42 | +CONTENT_CLAIMS_SERVICE_URL = "https://dev.claims.web3.storage" |
| 43 | +``` |
| 44 | +
|
| 45 | +If you want to enable the Rate Limiter and KV add the following too: |
| 46 | +```sh |
| 47 | +[[env.YOUR_USERNAME.unsafe.bindings]] |
| 48 | +name = "RATE_LIMITER" |
| 49 | +type = "ratelimit" |
| 50 | +namespace_id = "0" |
| 51 | +simple = { limit = 100, period = 60 } |
| 52 | + |
| 53 | +[[env.YOUR_USERNAME.kv_namespaces]] |
| 54 | +binding = "AUTH_TOKEN_METADATA" |
| 55 | +id = "YOUR_TOKEN" //FIXME how to obtain this token? |
| 56 | +``` |
| 57 | +
|
| 58 | +5. Start local server |
| 59 | +```sh |
| 60 | +npx wrangler dev -e YOUR_USERNAME |
| 61 | +``` |
| 62 | +
|
| 63 | +### Additional Tooling |
| 64 | +
|
| 65 | +*Kubo*: An IPFS implementation in Go |
| 66 | +We are going to use it to save testing content and get valid CIDs. |
| 67 | +
|
| 68 | +```sh |
| 69 | +docker pull ipfs/kubo:latest |
| 70 | +docker run --rm -it --net=host ipfs/kubo:latest |
| 71 | +``` |
| 72 | +
|
| 73 | +Then add the sample content to get a valid CID for testing |
| 74 | +```sh |
| 75 | +echo "hello world" | ipfs add --cid-version=1 |
| 76 | +``` |
| 77 | +
|
| 78 | +6. Sample Request |
| 79 | +```sh |
| 80 | +curl -XGET -i http://localhost |
| 81 | +``` |
| 82 | +
|
| 83 | +## Testing |
| 84 | +
|
| 85 | +Freeway is using miniflare v3 for testing which allows you to define the testing configurations in the JavaScript code (see `src/test/index.spec.js`). |
| 86 | +
|
| 87 | +Note: |
| 88 | +- Miniflare v3 doesn't support the Rate Limiting bidding for now, so we need to mock the rate limiting API to be able to use it in tests and in local development? |
| 89 | +
|
| 90 | +In order to run the existing tests you can execute the following commands: |
| 91 | +
|
| 92 | +**Miniflare Tests** |
| 93 | +```sh |
| 94 | +npm run test |
| 95 | +``` |
| 96 | +
|
| 97 | +**Unit Tests** |
| 98 | +```sh |
| 99 | +npm run test:unit |
| 100 | +``` |
| 101 | +
|
| 102 | +**Integration Tests** |
| 103 | +```sh |
| 104 | +TBD |
| 105 | +``` |
| 106 | +
|
13 | 107 | ## Contributing
|
14 | 108 |
|
15 | 109 | Feel free to join in. All welcome. Please read our [contributing guidelines](https://github.com/web3-storage/freeway/blob/main/CONTRIBUTING.md) and/or [open an issue](https://github.com/web3-storage/freeway/issues)!
|
|
0 commit comments