@nodeart/cloudflare-provisioning 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 16
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-npm:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v3
26
+ - uses: actions/setup-node@v3
27
+ with:
28
+ node-version: 16
29
+ registry-url: https://registry.npmjs.org/
30
+ - run: npm ci
31
+ - run: npm publish
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/cloudflare.js CHANGED
@@ -598,6 +598,27 @@ class CloudFlare {
598
598
 
599
599
  await this.createWorkerRoutes(workerRoutes)
600
600
  }
601
+
602
+ async setHotlinkProtection (value) {
603
+ const url = CLOUDFLARE_API_URL + `zones/${this.zoneId}/settings/hotlink_protection`
604
+
605
+ const { statusCode, body } = await request(url, {
606
+ method: 'PATCH',
607
+ headers: {
608
+ ...this.authorizationHeaders,
609
+ 'Content-Type': 'application/json'
610
+ },
611
+ body: JSON.stringify({ value })
612
+ })
613
+
614
+ const response = await body.json()
615
+
616
+ if (statusCode !== 200) {
617
+ throw new Error(`Could not change hotlink protection: ${statusCode}, error: ${JSON.stringify(response)}`)
618
+ }
619
+
620
+ return response
621
+ }
601
622
  }
602
623
 
603
624
  module.exports = CloudFlare
package/index.js CHANGED
@@ -19,7 +19,8 @@ const cloudflareSettingsHandlers = {
19
19
  '0-RTT': CloudFlare.prototype.set0RTT,
20
20
  argoSmartRouting: CloudFlare.prototype.setArgoSmartRouting,
21
21
  workers: CloudFlare.prototype.rewriteWorkerRoutes,
22
- pageRules: CloudFlare.prototype.rewritePageRules
22
+ pageRules: CloudFlare.prototype.rewritePageRules,
23
+ hotlinkProtection: CloudFlare.prototype.setHotlinkProtection
23
24
  }
24
25
 
25
26
  function substituteDomainName (settings, domainName) {
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@nodeart/cloudflare-provisioning",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
+ "test": "standard",
7
8
  "lint": "standard",
8
9
  "prepare": "husky install"
9
10
  },
package/template.js CHANGED
@@ -124,5 +124,8 @@ module.exports = {
124
124
  },
125
125
  traffic: {
126
126
  argoSmartRouting: 'on'
127
+ },
128
+ scrapeShield: {
129
+ hotlinkProtection: 'off'
127
130
  }
128
131
  }