Compare commits
86 Commits
Author | SHA1 | Date | |
---|---|---|---|
c65790e2f9 | |||
7ec0fe78fc | |||
12f4456ebd | |||
3e8cf73877 | |||
0032292714 | |||
ead87ceb63 | |||
04d70a4d12 | |||
8da43a79d3 | |||
3153021190 | |||
82701c19e7 | |||
d3a68b4fef | |||
c4c1367306 | |||
1f5352d9f5 | |||
f652cc72fe | |||
f510408fce | |||
e250e9b1a2 | |||
5a9b7bbeee | |||
1158b4ff99 | |||
8eb777dd45 | |||
acf5c242d3 | |||
9e9dd8d935 | |||
b7cc500f4d | |||
8a4126a49c | |||
b86391ca00 | |||
92682c1276 | |||
05677231f7 | |||
9c036925fd | |||
d3d5f72193 | |||
3d7c0e6b64 | |||
4faefb0bd7 | |||
162fff134e | |||
426237b2a7 | |||
b2d48d793a | |||
54282bdc14 | |||
208fba0887 | |||
2f065b57fc | |||
3503fbc7b3 | |||
1db3342353 | |||
03380b0d28 | |||
4fe7ec8a66 | |||
a050271574 | |||
d54884ded7 | |||
30f7fa9c8a | |||
6bc7edceb9 | |||
2ee94dd179 | |||
a4a006e490 | |||
98d5127846 | |||
f63d8abfc6 | |||
266f84f33a | |||
6400e0f038 | |||
b4838566ac | |||
803f1ce41a | |||
8a8adb48c6 | |||
078731fe7b | |||
bf15b8aec7 | |||
55b305ca1c | |||
9699e4bf76 | |||
0692d16dd7 | |||
c76643d700 | |||
de088ba550 | |||
1ecf660368 | |||
a04ce339f2 | |||
feed201dc1 | |||
cb73164c8f | |||
4758f31132 | |||
5a0ab5080d | |||
26bb194814 | |||
4a656cf7f1 | |||
9a35e69ab6 | |||
757a9acd09 | |||
9cb3c1508e | |||
d25033b84b | |||
941611b7fb | |||
441d66d6f6 | |||
ba2d6f4237 | |||
ff71de8f6c | |||
e99d597c12 | |||
f44698078e | |||
0ed9c7f4f4 | |||
f4d4bc238b | |||
f4c2bb6e5b | |||
b2182ec63d | |||
6cc91c0a5e | |||
69ef50f69c | |||
71dcdd0d66 | |||
229b652c69 |
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,7 +1,22 @@
|
|||||||
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
ts/typings/
|
pages/
|
||||||
ts/**/*.js
|
|
||||||
ts/**/*.js.map
|
# installs
|
||||||
.idea/
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
126
.gitlab-ci.yml
Normal file
126
.gitlab-ci.yml
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- security
|
||||||
|
- test
|
||||||
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
release:
|
||||||
|
stage: release
|
||||||
|
script:
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
pages:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
12
.travis.yml
12
.travis.yml
@ -1,12 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- '4'
|
|
||||||
- stable
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: uWqO634z8xMWI8tcIpSvUeVeG4ypX5fppXWxrSKbO5zOHCHGqJK90XiGFfKUekMf0cYQPb5dLT5+J/3nd4mf4KtU3+v1OK6ZikEqn/PcSeqOmK7EnI9wDFZwDTgJWIn0lRwX2mfB9meblSZ7XthTXumX78fmRTyeyImLm9P0ak+CrNzs8rzKauBoqeVryOez4/LaH3f0kxSz7o7zYLxFqx5xjQ7TFqd1kkVTf4pSQanLHY3z+7+mKrkbcNVxx2gF76hyx6E4pntSJHrOEE/VU/KMk2B6yzrVWYUHUiSRGYOV9U17YaaWlC9DZmnS1cvYcqq3YNujTwPWtci3It9S98hLrSTnCCqin6xhj8IuV6U4WADiXOUvNKuTRcd0/leQ4w3xpPJ1FR2gRtEhwQ0NsnY0vL9tuRAW71lf31122TTJI8lJQNrnaeIGbX7eE0Pq0jeTpmM2W/Tl8pl6s6zBjlEC/mCynQq1pBiz7UmxMYCPE162I8V5USeZOBLzDPZV2y7hmPWjMrWTT+i/IpFmXHjQtVrwlyU6fCOeYHgK/5GdyhnrRYYlx+ce6pCn4tmkVxduimC3m1G8cTkPl00fIpy7KSVcaeQrc1N+KQUqK4FpIjeqB904SVPsI5v3P7sdobaT1aqFqszhR+JK5tXaoesew8R2RncjFK69J7DHJWk=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/cflare
|
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Push.Rocks
|
Copyright (c) 2016 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
25
README.md
25
README.md
@ -1,25 +0,0 @@
|
|||||||
# cflare
|
|
||||||
allows you to manage cloudflare from CoreOS
|
|
||||||
|
|
||||||
> Note: this package is still in alpha, so some things do not yet work.
|
|
||||||
I (Phil from Lossless) expect this package to be ready 1. of June 2016.
|
|
||||||
|
|
||||||
## Status
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var cflare = require("cflare");
|
|
||||||
var cflareInstance = new cflare();
|
|
||||||
|
|
||||||
cflareInstance.auth({
|
|
||||||
email:"",
|
|
||||||
key:""
|
|
||||||
});
|
|
||||||
|
|
||||||
cflareInstance.createRecord();
|
|
||||||
cflareInstance.removeRecord();
|
|
||||||
cflareInstance.copyRecord();
|
|
||||||
cflareInstance.listRecords();
|
|
||||||
cflareInstance.listDomains();
|
|
||||||
```
|
|
3
dist/cflare.classes.helpers.js
vendored
3
dist/cflare.classes.helpers.js
vendored
@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJjZmxhcmUuY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOltdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
|
10
dist/cflare.classes.js
vendored
10
dist/cflare.classes.js
vendored
@ -1,10 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var cflare = (function () {
|
|
||||||
function cflare() {
|
|
||||||
}
|
|
||||||
;
|
|
||||||
return cflare;
|
|
||||||
}());
|
|
||||||
;
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5jbGFzc2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFJQTtJQUdJO0lBRUEsQ0FBQzs7SUFFTCxhQUFDO0FBQUQsQ0FQQSxBQU9DLElBQUE7QUFBQSxDQUFDIiwiZmlsZSI6ImNmbGFyZS5jbGFzc2VzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9jZmxhcmUucGx1Z2luc1wiKTtcbmltcG9ydCBoZWxwZXJzID0gcmVxdWlyZShcIi4vY2ZsYXJlLmNsYXNzZXMuaGVscGVyc1wiKTtcblxuY2xhc3MgY2ZsYXJlIHtcbiAgICBwcml2YXRlIGF1dGhFbWFpbDpzdHJpbmc7XG4gICAgcHJpdmF0ZSBhdXRoS2V5OnN0cmluZztcbiAgICBjb25zdHJ1Y3Rvcigpe1xuICAgICAgICBcbiAgICB9O1xuICAgIFxufTsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
6
dist/cflare.plugins.js
vendored
6
dist/cflare.plugins.js
vendored
@ -1,6 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
exports.beautylog = require("beautylog");
|
|
||||||
exports.request = require("request");
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDakMsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDakMsZUFBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQyIsImZpbGUiOiJjZmxhcmUucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgcmVxdWVzdCA9IHJlcXVpcmUoXCJyZXF1ZXN0XCIpOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "mojoio",
|
||||||
|
"gitrepo": "cloudflare",
|
||||||
|
"shortDescription": "easy cloudflare management",
|
||||||
|
"npmPackagename": "@mojoio/cloudflare",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1695
package-lock.json
generated
Normal file
1695
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
package.json
49
package.json
@ -1,30 +1,55 @@
|
|||||||
{
|
{
|
||||||
"name": "cflare",
|
"name": "@mojoio/cloudflare",
|
||||||
"version": "0.0.1",
|
"version": "4.0.1",
|
||||||
"description": "cloudflare management for CoreOS",
|
"private": false,
|
||||||
|
"description": "easy cloudflare management",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/pushrocks/cflare.git"
|
"url": "git+https://gitlab.com/pushrocks/cflare.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"CoreOS",
|
"Push.Rocks",
|
||||||
"cloudflare"
|
"cloudflare"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/cflare/issues"
|
"url": "https://gitlab.com/pushrocks/cflare/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/cflare#readme",
|
"homepage": "https://gitlab.com/pushrocks/cflare#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^4.1.2",
|
"@pushrocks/smartdelay": "^2.0.6",
|
||||||
"request": "^2.72.0"
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
|
"@pushrocks/smartrequest": "^1.1.47",
|
||||||
|
"@pushrocks/smartstring": "^3.0.18",
|
||||||
|
"@tsclass/tsclass": "^3.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts": "^5.0.4"
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
}
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
|
"@gitzone/tstest": "^1.0.28",
|
||||||
|
"@pushrocks/qenv": "^4.0.6",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
|
"@types/node": "^13.7.0",
|
||||||
|
"tslint": "^6.0.0",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_web/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
49
readme.md
Normal file
49
readme.md
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# @mojoio/cloudflare
|
||||||
|
easy cloudflare management
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/cloudflare)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/mojoio/cloudflare)
|
||||||
|
* [github.com (source mirror)](https://github.com/mojoio/cloudflare)
|
||||||
|
* [docs (typedoc)](https://mojoio.gitlab.io/cloudflare/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/mojoio/cloudflare/commits/master)
|
||||||
|
[](https://gitlab.com/mojoio/cloudflare/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@mojoio/cloudflare)
|
||||||
|
[](https://snyk.io/test/npm/@mojoio/cloudflare)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import * as cflare from '@mojoio/cloudflare';
|
||||||
|
|
||||||
|
const myCflareAccount = new cflare.CflareAccount();
|
||||||
|
testCflareAccount.auth({
|
||||||
|
email: 'someuser@example.com',
|
||||||
|
key: 'someLongApiKey'
|
||||||
|
});
|
||||||
|
|
||||||
|
const myAsyncCflareManagement = async () => {
|
||||||
|
// get things
|
||||||
|
const myZones = await myCflareAccount.listZones(); // zones are fully typed
|
||||||
|
const myIdForADomain = await myCflareAccount.getZoneId('example.com'); // type number
|
||||||
|
const myRecordsForADomain = await myCflareAccount.listRecords('example.com'); // records are fully typed
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
95
test/test.ts
Normal file
95
test/test.ts
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
// tslint:disable-next-line: no-implicit-dependencies
|
||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
// tslint:disable-next-line: no-implicit-dependencies
|
||||||
|
import { Qenv } from '@pushrocks/qenv';
|
||||||
|
|
||||||
|
import cloudflare = require('../ts/index');
|
||||||
|
|
||||||
|
const testQenv = new Qenv(process.cwd(), process.cwd() + '/.nogit');
|
||||||
|
|
||||||
|
const randomPrefix = Math.floor(Math.random() * 2000);
|
||||||
|
let testCloudflareAccount: cloudflare.CloudflareAccount;
|
||||||
|
|
||||||
|
tap.test('should create a valid instance of CloudflareAccount', async () => {
|
||||||
|
testCloudflareAccount = new cloudflare.CloudflareAccount({
|
||||||
|
email: testQenv.getEnvVarOnDemand('CF_EMAIL'),
|
||||||
|
key: testQenv.getEnvVarOnDemand('CF_KEY')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.listZones() -> should display an entire account', async tools => {
|
||||||
|
tools.timeout(600000);
|
||||||
|
const result = await testCloudflareAccount.convenience.listZones();
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test(
|
||||||
|
'.getZoneId(domainName) -> should get an Cloudflare Id for a domain string',
|
||||||
|
async tools => {
|
||||||
|
tools.timeout(600000);
|
||||||
|
await testCloudflareAccount.getZoneId('bleu.de');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
tap.test(
|
||||||
|
'.listRecords(domainName) -> should list all records for a specific Domain Name',
|
||||||
|
async tools => {
|
||||||
|
tools.timeout(600000);
|
||||||
|
await testCloudflareAccount.convenience.listRecords('bleu.de').then(async responseArg => {
|
||||||
|
console.log(responseArg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
tap.test('should create a valid record for a subdomain', async tools => {
|
||||||
|
tools.timeout(600000);
|
||||||
|
await testCloudflareAccount.convenience.createRecord(
|
||||||
|
`${randomPrefix}subdomain.bleu.de`,
|
||||||
|
'A',
|
||||||
|
'127.0.0.1'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should get a record from Cloudflare', async tools => {
|
||||||
|
tools.timeout(600000);
|
||||||
|
await testCloudflareAccount.convenience
|
||||||
|
.getRecord(`${randomPrefix}subdomain.bleu.de`, 'A')
|
||||||
|
.then(responseArg => {
|
||||||
|
console.log(responseArg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should remove a subdomain record from Cloudflare', async tools => {
|
||||||
|
tools.timeout(600000);
|
||||||
|
await testCloudflareAccount.convenience
|
||||||
|
.removeRecord(`${randomPrefix}subdomain.bleu.de`, 'A')
|
||||||
|
.then(async responseArg => {
|
||||||
|
console.log(responseArg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.purge(some.domain) -> should purge everything', async () => {
|
||||||
|
await testCloudflareAccount.convenience.purgeZone('bleu.de');
|
||||||
|
});
|
||||||
|
|
||||||
|
// WORKERS
|
||||||
|
tap.test('should create a worker', async () => {
|
||||||
|
const worker = await testCloudflareAccount.workerManager.createWorker(
|
||||||
|
'myawesomescript',
|
||||||
|
`addEventListener('fetch', event => { event.respondWith(fetch(event.request)) })`
|
||||||
|
);
|
||||||
|
await worker.setRoutes([
|
||||||
|
{
|
||||||
|
zoneName: 'bleu.de',
|
||||||
|
pattern: 'https://*bleu.de/hello'
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
console.log(worker);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should get workers', async () => {
|
||||||
|
const workerArray = await testCloudflareAccount.workerManager.listWorkers();
|
||||||
|
console.log(workerArray);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,2 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
import plugins = require("./cflare.plugins");
|
|
@ -1,12 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
import plugins = require("./cflare.plugins");
|
|
||||||
import helpers = require("./cflare.classes.helpers");
|
|
||||||
|
|
||||||
class cflare {
|
|
||||||
private authEmail:string;
|
|
||||||
private authKey:string;
|
|
||||||
constructor(){
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
@ -1,3 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
export let beautylog = require("beautylog");
|
|
||||||
export let request = require("request");
|
|
239
ts/cloudflare.classes.account.ts
Normal file
239
ts/cloudflare.classes.account.ts
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
import plugins = require('./cloudflare.plugins');
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
// interfaces
|
||||||
|
import { WorkerManager } from './cloudflare.classes.workermanager';
|
||||||
|
import { ZoneManager } from './cloudflare.classes.zonemanager';
|
||||||
|
|
||||||
|
export class CloudflareAccount {
|
||||||
|
private authEmail: string;
|
||||||
|
private authKey: string;
|
||||||
|
private accountIdentifier: string;
|
||||||
|
|
||||||
|
public workerManager = new WorkerManager(this);
|
||||||
|
public zoneManager = new ZoneManager(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor sets auth information on the CloudflareAccountInstance
|
||||||
|
* @param optionsArg
|
||||||
|
*/
|
||||||
|
constructor(optionsArg: { email: string; key: string }) {
|
||||||
|
this.authEmail = optionsArg.email;
|
||||||
|
this.authKey = optionsArg.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets you the account identifier
|
||||||
|
*/
|
||||||
|
public async getAccountIdentifier() {
|
||||||
|
if (!this.accountIdentifier) {
|
||||||
|
const route = `/accounts?page=1&per_page=20&direction=desc`;
|
||||||
|
const response: any = await this.request('GET', route);
|
||||||
|
this.accountIdentifier = response.result[0].id;
|
||||||
|
}
|
||||||
|
return this.accountIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets a zone id of a domain from cloudflare
|
||||||
|
* @param domainName
|
||||||
|
*/
|
||||||
|
public async getZoneId(domainName: string) {
|
||||||
|
const domain = new plugins.smartstring.Domain(domainName);
|
||||||
|
const zoneArray = await this.convenience.listZones(domain.zoneName);
|
||||||
|
const filteredResponse = zoneArray.filter(zoneArg => {
|
||||||
|
return zoneArg.name === domainName;
|
||||||
|
});
|
||||||
|
if (filteredResponse.length >= 1) {
|
||||||
|
return filteredResponse[0].id;
|
||||||
|
} else {
|
||||||
|
plugins.smartlog.defaultLogger.log(
|
||||||
|
'error',
|
||||||
|
`the domain ${domainName} does not appear to be in this account!`
|
||||||
|
);
|
||||||
|
throw new Error(`the domain ${domainName} does not appear to be in this account!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public convenience = {
|
||||||
|
/**
|
||||||
|
* gets a record
|
||||||
|
* @param domainNameArg
|
||||||
|
* @param typeArg
|
||||||
|
*/
|
||||||
|
getRecord: async (
|
||||||
|
domainNameArg: string,
|
||||||
|
typeArg: plugins.tsclass.network.TDnsRecord
|
||||||
|
): Promise<interfaces.ICflareRecord> => {
|
||||||
|
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||||
|
const recordArrayArg = await this.convenience.listRecords(domain.zoneName);
|
||||||
|
const filteredResponse = recordArrayArg.filter(recordArg => {
|
||||||
|
return recordArg.type === typeArg && recordArg.name === domainNameArg;
|
||||||
|
});
|
||||||
|
return filteredResponse[0];
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* creates a record
|
||||||
|
*/
|
||||||
|
createRecord: async (
|
||||||
|
domainNameArg: string,
|
||||||
|
typeArg: plugins.tsclass.network.TDnsRecord,
|
||||||
|
contentArg: string
|
||||||
|
): Promise<any> => {
|
||||||
|
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||||
|
const domainIdArg = await this.getZoneId(domain.zoneName);
|
||||||
|
const dataObject = {
|
||||||
|
name: domain.fullName,
|
||||||
|
type: typeArg,
|
||||||
|
content: contentArg
|
||||||
|
};
|
||||||
|
const response = await this.request(
|
||||||
|
'POST',
|
||||||
|
'/zones/' + domainIdArg + '/dns_records',
|
||||||
|
dataObject
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* removes a record from Cloudflare
|
||||||
|
* @param domainNameArg
|
||||||
|
* @param typeArg
|
||||||
|
*/
|
||||||
|
removeRecord: async (
|
||||||
|
domainNameArg: string,
|
||||||
|
typeArg: plugins.tsclass.network.TDnsRecord
|
||||||
|
): Promise<any> => {
|
||||||
|
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||||
|
const cflareRecord = await this.convenience.getRecord(domain.fullName, typeArg);
|
||||||
|
if (cflareRecord) {
|
||||||
|
const requestRoute: string = `/zones/${cflareRecord.zone_id}/dns_records/${cflareRecord.id}`;
|
||||||
|
return await this.request('DELETE', requestRoute);
|
||||||
|
} else {
|
||||||
|
throw new Error(`could not remove record for ${domainNameArg} with type ${typeArg}`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* cleanrecord allows the cleaning of any previous records to avoid unwanted sideeffects
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* updates a record
|
||||||
|
* @param domainNameArg
|
||||||
|
* @param typeArg
|
||||||
|
* @param valueArg
|
||||||
|
*/
|
||||||
|
updateRecord: async (domainNameArg: string, typeArg: string, valueArg) => {
|
||||||
|
// TODO: implement
|
||||||
|
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* list all records of a specified domain name
|
||||||
|
* @param domainNameArg - the domain name that you want to get the records from
|
||||||
|
*/
|
||||||
|
listRecords: async (domainNameArg: string): Promise<interfaces.ICflareRecord[]> => {
|
||||||
|
const domain = new plugins.smartstring.Domain(domainNameArg);
|
||||||
|
const domainId = await this.getZoneId(domain.zoneName);
|
||||||
|
const responseArg: any = await this.request(
|
||||||
|
'GET',
|
||||||
|
'/zones/' + domainId + '/dns_records?per_page=100'
|
||||||
|
);
|
||||||
|
const result: interfaces.ICflareRecord[] = responseArg.result;
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* list all zones in the associated authenticated account
|
||||||
|
* @param domainName
|
||||||
|
*/
|
||||||
|
listZones: async (domainName?: string): Promise<interfaces.ICflareZone[]> => {
|
||||||
|
// TODO: handle pagination
|
||||||
|
let requestRoute = `/zones?per_page=50`;
|
||||||
|
|
||||||
|
// may be optionally filtered by domain name
|
||||||
|
if (domainName) {
|
||||||
|
requestRoute = `${requestRoute}&name=${domainName}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response: any = await this.request('GET', requestRoute);
|
||||||
|
const result = response.result;
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* purges a zone
|
||||||
|
*/
|
||||||
|
purgeZone: async (domainName: string): Promise<void> => {
|
||||||
|
const domain = new plugins.smartstring.Domain(domainName);
|
||||||
|
const domainId = await this.getZoneId(domain.zoneName);
|
||||||
|
const requestUrl = `/zones/${domainId}/purge_cache`;
|
||||||
|
const payload = {
|
||||||
|
purge_everything: true
|
||||||
|
};
|
||||||
|
const respone = await this.request('DELETE', requestUrl, payload);
|
||||||
|
},
|
||||||
|
// acme convenience functions
|
||||||
|
acmeSetDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
|
||||||
|
await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT');
|
||||||
|
await this.convenience.createRecord(dnsChallenge.hostName, 'TXT', dnsChallenge.challenge);
|
||||||
|
},
|
||||||
|
acmeRemoveDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => {
|
||||||
|
await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public request(
|
||||||
|
methodArg: string,
|
||||||
|
routeArg: string,
|
||||||
|
dataArg: any = {},
|
||||||
|
requestHeadersArg = {}
|
||||||
|
): Promise<any> {
|
||||||
|
const done = plugins.smartpromise.defer();
|
||||||
|
const options: plugins.smartrequest.ISmartRequestOptions = {
|
||||||
|
method: methodArg,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Auth-Email': this.authEmail,
|
||||||
|
'X-Auth-Key': this.authKey,
|
||||||
|
'Content-Length': Buffer.byteLength(JSON.stringify(dataArg)),
|
||||||
|
...requestHeadersArg
|
||||||
|
},
|
||||||
|
requestBody: dataArg
|
||||||
|
};
|
||||||
|
|
||||||
|
// console.log(options);
|
||||||
|
|
||||||
|
let retryCount = 0; // count the amount of retries
|
||||||
|
|
||||||
|
const makeRequest = async () => {
|
||||||
|
const response: any = await plugins.smartrequest.request(
|
||||||
|
`https://api.cloudflare.com/client/v4${routeArg}`,
|
||||||
|
options
|
||||||
|
);
|
||||||
|
if (response.statusCode === 200) {
|
||||||
|
done.resolve(response.body);
|
||||||
|
} else if (response.statusCode === 429) {
|
||||||
|
console.log('rate limited! Waiting for retry!');
|
||||||
|
retryRequest();
|
||||||
|
} else if (response.statusCode === 400) {
|
||||||
|
console.log(`bad request for route ${routeArg}! Going to retry!`);
|
||||||
|
console.log(response.body);
|
||||||
|
} else {
|
||||||
|
console.log(response.statusCode);
|
||||||
|
done.reject(new Error('request failed'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const retryRequest = async (
|
||||||
|
delayTimeArg = Math.floor(Math.random() * (60000 - 8000) + 8000)
|
||||||
|
) => {
|
||||||
|
console.log(`retry started and waiting for ${delayTimeArg} ms`);
|
||||||
|
await plugins.smartdelay.delayFor(delayTimeArg);
|
||||||
|
if (retryCount < 10) {
|
||||||
|
retryCount++;
|
||||||
|
return await makeRequest();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
makeRequest();
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
private authCheck() {
|
||||||
|
return this.authEmail && this.authKey; // check if auth is available
|
||||||
|
}
|
||||||
|
}
|
0
ts/cloudflare.classes.record.ts
Normal file
0
ts/cloudflare.classes.record.ts
Normal file
92
ts/cloudflare.classes.worker.ts
Normal file
92
ts/cloudflare.classes.worker.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import * as plugins from './cloudflare.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
import { WorkerManager } from './cloudflare.classes.workermanager';
|
||||||
|
|
||||||
|
export interface IWorkerRoute extends interfaces.ICflareWorkerRoute {
|
||||||
|
zoneName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CloudflareWorker {
|
||||||
|
// STATIC
|
||||||
|
public static async fromApiObject(
|
||||||
|
workerManager: WorkerManager,
|
||||||
|
apiObject
|
||||||
|
): Promise<CloudflareWorker> {
|
||||||
|
const newWorker = new CloudflareWorker(workerManager);
|
||||||
|
Object.assign(newWorker, apiObject);
|
||||||
|
await newWorker.getRoutes();
|
||||||
|
return newWorker;
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSTANCE
|
||||||
|
private workerManager: WorkerManager;
|
||||||
|
|
||||||
|
public script: string;
|
||||||
|
public id: string;
|
||||||
|
public etag: string;
|
||||||
|
// tslint:disable-next-line: variable-name
|
||||||
|
public created_on: string;
|
||||||
|
// tslint:disable-next-line: variable-name
|
||||||
|
public modified_on: string;
|
||||||
|
|
||||||
|
public routes: IWorkerRoute[] = [];
|
||||||
|
constructor(workerManagerArg: WorkerManager) {
|
||||||
|
this.workerManager = workerManagerArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets all routes for a worker
|
||||||
|
*/
|
||||||
|
public async getRoutes() {
|
||||||
|
const zones = await this.workerManager.cfAccount.convenience.listZones();
|
||||||
|
for (const zone of zones) {
|
||||||
|
const requestRoute = `/zones/${zone.id}/workers/routes`;
|
||||||
|
const response: {
|
||||||
|
result: interfaces.ICflareWorkerRoute[];
|
||||||
|
} = await this.workerManager.cfAccount.request('GET', requestRoute);
|
||||||
|
for (const route of response.result) {
|
||||||
|
console.log('hey');
|
||||||
|
console.log(route);
|
||||||
|
console.log(this.id);
|
||||||
|
if (route.script === this.id) {
|
||||||
|
this.routes.push({ ...route, zoneName: zone.name });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async setRoutes(routeArray: Array<{ zoneName: string; pattern: string }>) {
|
||||||
|
for (const newRoute of routeArray) {
|
||||||
|
// lets determine wether a route is new, needs an update or already up to date.
|
||||||
|
let routeStatus: 'new' | 'needsUpdate' | 'alreadyUpToDate' = 'new';
|
||||||
|
let routeIdForUpdate: string;
|
||||||
|
for (const existingRoute of this.routes) {
|
||||||
|
if (existingRoute.pattern === newRoute.pattern) {
|
||||||
|
routeStatus = 'needsUpdate';
|
||||||
|
routeIdForUpdate = existingRoute.id;
|
||||||
|
if (existingRoute.script === this.id) {
|
||||||
|
routeStatus = 'alreadyUpToDate';
|
||||||
|
plugins.smartlog.defaultLogger.log('info', `route already exists, no update needed`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// lets care about actually setting routes
|
||||||
|
if (routeStatus === 'new') {
|
||||||
|
const zoneId = await this.workerManager.cfAccount.getZoneId(newRoute.zoneName);
|
||||||
|
const requestRoute = `/zones/${zoneId}/workers/routes`;
|
||||||
|
await this.workerManager.cfAccount.request('POST', requestRoute, {
|
||||||
|
pattern: newRoute.pattern,
|
||||||
|
script: this.id
|
||||||
|
});
|
||||||
|
} else if (routeStatus === 'needsUpdate') {
|
||||||
|
const zoneId = await this.workerManager.cfAccount.getZoneId(newRoute.zoneName);
|
||||||
|
const requestRoute = `/zones/${zoneId}/workers/routes/${routeIdForUpdate}`;
|
||||||
|
await this.workerManager.cfAccount.request('PUT', requestRoute, {
|
||||||
|
pattern: newRoute.pattern,
|
||||||
|
script: this.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
ts/cloudflare.classes.workermanager.ts
Normal file
36
ts/cloudflare.classes.workermanager.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import * as plugins from './cloudflare.plugins';
|
||||||
|
import { CloudflareAccount } from './cloudflare.classes.account';
|
||||||
|
import { CloudflareWorker } from './cloudflare.classes.worker';
|
||||||
|
|
||||||
|
export class WorkerManager {
|
||||||
|
public cfAccount: CloudflareAccount;
|
||||||
|
|
||||||
|
constructor(cfAccountArg: CloudflareAccount) {
|
||||||
|
this.cfAccount = cfAccountArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async createWorker(workerName: string, workerScript: string): Promise<CloudflareWorker> {
|
||||||
|
const accountIdentifier = await this.cfAccount.getAccountIdentifier();
|
||||||
|
const route = `/accounts/${accountIdentifier}/workers/scripts/${workerName}`;
|
||||||
|
const responseBody = await this.cfAccount.request('PUT', route, workerScript, {
|
||||||
|
'Content-Type': 'application/javascript',
|
||||||
|
'Content-Length': Buffer.byteLength(workerScript)
|
||||||
|
});
|
||||||
|
return CloudflareWorker.fromApiObject(this, responseBody.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists workers
|
||||||
|
*/
|
||||||
|
public async listWorkers() {
|
||||||
|
const accountIdentifier = await this.cfAccount.getAccountIdentifier();
|
||||||
|
const route = `/accounts/${accountIdentifier}/workers/scripts`;
|
||||||
|
const response = await this.cfAccount.request('GET', route);
|
||||||
|
const results = response.result;
|
||||||
|
const workers: CloudflareWorker[] = [];
|
||||||
|
for (const apiObject of results) {
|
||||||
|
workers.push(await CloudflareWorker.fromApiObject(this, apiObject));
|
||||||
|
}
|
||||||
|
return workers;
|
||||||
|
}
|
||||||
|
}
|
6
ts/cloudflare.classes.zone.ts
Normal file
6
ts/cloudflare.classes.zone.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from './cloudflare.plugins';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
export class CloudflareZone {
|
||||||
|
public static async createFromApiObject() {}
|
||||||
|
}
|
13
ts/cloudflare.classes.zonemanager.ts
Normal file
13
ts/cloudflare.classes.zonemanager.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import * as plugins from './cloudflare.plugins';
|
||||||
|
import { CloudflareAccount } from './cloudflare.classes.account';
|
||||||
|
|
||||||
|
export class ZoneManager {
|
||||||
|
public cfAccount: CloudflareAccount;
|
||||||
|
public zoneName: string;
|
||||||
|
|
||||||
|
constructor(cfAccountArg: CloudflareAccount) {
|
||||||
|
this.cfAccount = cfAccountArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getZones() {}
|
||||||
|
}
|
8
ts/cloudflare.plugins.ts
Normal file
8
ts/cloudflare.plugins.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
import * as smartstring from '@pushrocks/smartstring';
|
||||||
|
import * as tsclass from '@tsclass/tsclass';
|
||||||
|
|
||||||
|
export { smartlog, smartpromise, smartdelay, smartrequest, smartstring, tsclass };
|
@ -1,2 +1,2 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
export { CloudflareAccount } from './cloudflare.classes.account';
|
||||||
import plugins = require("./cflare.plugins");
|
export { CloudflareWorker } from './cloudflare.classes.worker';
|
||||||
|
15
ts/interfaces/cloudflare.api.record.ts
Normal file
15
ts/interfaces/cloudflare.api.record.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export interface ICflareRecord {
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
name: string;
|
||||||
|
content: string;
|
||||||
|
proxiable: boolean;
|
||||||
|
proxied: boolean;
|
||||||
|
ttl: number;
|
||||||
|
locked: boolean;
|
||||||
|
zone_id: string;
|
||||||
|
zone_name: string;
|
||||||
|
created_on: string;
|
||||||
|
modified_on: string;
|
||||||
|
data: any;
|
||||||
|
}
|
5
ts/interfaces/cloudflare.api.workerroute.ts
Normal file
5
ts/interfaces/cloudflare.api.workerroute.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface ICflareWorkerRoute {
|
||||||
|
id: string;
|
||||||
|
pattern: string;
|
||||||
|
script: string;
|
||||||
|
}
|
41
ts/interfaces/cloudflare.api.zone.ts
Normal file
41
ts/interfaces/cloudflare.api.zone.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
export interface ICflareZone {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
development_mode: number;
|
||||||
|
original_name_servers: string[];
|
||||||
|
original_registrar: string;
|
||||||
|
original_dnshost: string;
|
||||||
|
created_on: string;
|
||||||
|
modified_on: string;
|
||||||
|
name_servers: string[];
|
||||||
|
owner: {
|
||||||
|
id: string;
|
||||||
|
email: string;
|
||||||
|
owner_type: string;
|
||||||
|
};
|
||||||
|
permissions: string[];
|
||||||
|
plan: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
price: number;
|
||||||
|
currency: string;
|
||||||
|
frequency: string;
|
||||||
|
legacy_id: string;
|
||||||
|
is_subscribed: boolean;
|
||||||
|
can_subscribe: boolean;
|
||||||
|
};
|
||||||
|
plan_pending: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
price: number;
|
||||||
|
currency: string;
|
||||||
|
frequency: string;
|
||||||
|
legacy_id: string;
|
||||||
|
is_subscribed: string;
|
||||||
|
can_subscribe: string;
|
||||||
|
};
|
||||||
|
status: string;
|
||||||
|
paused: boolean;
|
||||||
|
type: string;
|
||||||
|
checked_on: string;
|
||||||
|
}
|
3
ts/interfaces/index.ts
Normal file
3
ts/interfaces/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from './cloudflare.api.record';
|
||||||
|
export * from './cloudflare.api.zone';
|
||||||
|
export * from './cloudflare.api.workerroute';
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"version": false,
|
|
||||||
"dependencies": {},
|
|
||||||
"ambientDependencies": {
|
|
||||||
"colors": "registry:dt/colors#0.6.0-1+20160425153322",
|
|
||||||
"node": "registry:dt/node#4.0.0+20160423143914"
|
|
||||||
}
|
|
||||||
}
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
|
}
|
Reference in New Issue
Block a user