Apply Prettier to config and markdown files

This commit is contained in:
Zaid Abdulla committed 2021-01-07 01:29:22 -08:00
1 parent 5571ce96b4
commit edcee33780
12 files changed
+136 -151

No files matched your search

-2
View File
@@ -1,2 +0,0 @@
!/bin/.*.ts
!/tools/.*.ts
+16 -5
View File
@@ -8,19 +8,30 @@
"project": "./tsconfig.json" "project": "./tsconfig.json"
}, },
"plugins": ["@typescript-eslint"], "plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"], "extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"rules": { "rules": {
"no-shadow": ["error", { "allow": ["err"] }], "no-shadow": ["error", { "allow": ["err"] }],
"handle-callback-err": "error", "handle-callback-err": "error",
"prefer-arrow-callback": "error", "prefer-arrow-callback": "error",
"curly": ["error", "multi-or-nest", "consistent"], "curly": ["error", "multi-or-nest", "consistent"],
"no-buffer-constructor": "error", "no-buffer-constructor": "error",
"prefer-const": ["error", {"destructuring": "all"}], "prefer-const": ["error", { "destructuring": "all" }],
"eqeqeq": ["error", "always", {"null": "ignore"}], "eqeqeq": ["error", "always", { "null": "ignore" }],
"no-return-await": "error", "no-return-await": "error",
"@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-use-before-define": ["error", { "functions": false }], "@typescript-eslint/no-use-before-define": [
"@typescript-eslint/explicit-function-return-type": ["error", { "allowExpressions": true }], "error",
{ "functions": false }
],
"@typescript-eslint/explicit-function-return-type": [
"error",
{ "allowExpressions": true }
],
"@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-floating-promises": "error",
"require-atomic-updates": 0, "require-atomic-updates": 0,
"no-prototype-builtins": 0 "no-prototype-builtins": 0
-2
View File
@@ -1,6 +1,4 @@
*~ *~
node_modules node_modules
dist dist
bin/.*.ts
tools/.*.ts
docs/_build docs/_build
-25
View File
@@ -1,25 +0,0 @@
*~
.npmignore
config/config.json
config/cwmp.key
config/cwmp.crt
config/cwmp.ca-bundle
config/nbi.key
config/nbi.crt
config/nbi.ca-bundle
config/fs.key
config/fs.crt
config/fs.ca-bundle
config/ext
debug/*
!debug/.gitkeep
dist
.eslintrc.json
.eslintignore
ava.config.js
tsconfig.json
bin/.*
tools/.*
+2
View File
@@ -0,0 +1,2 @@
dist
npm-shrinkwrap.json
+72 -71
View File
@@ -3,18 +3,18 @@
## 1.2.3 (2020-10-26) ## 1.2.3 (2020-10-26)
- New config option 'cwmp.skipWritableCheck' for when some CPEs incorrectly - New config option 'cwmp.skipWritableCheck' for when some CPEs incorrectly
report writable parameters as non-writable. When set to true, the scripts will report writable parameters as non-writable. When set to true, the scripts will
no longer respect the 'writable' attribute of the CPE parameters and will send no longer respect the 'writable' attribute of the CPE parameters and will send
a SetParamteerValues, AddObject, or DeleteObject request anyway. a SetParamteerValues, AddObject, or DeleteObject request anyway.
- Tags no longer restrict what characters are allowed. Any character other than - Tags no longer restrict what characters are allowed. Any character other than
alphanumeric characters, hyphen, or underscore is now encoded in the data alphanumeric characters, hyphen, or underscore is now encoded in the data
model (i.e. Tags.\<tag>) using its hex value preceded by "0x". model (i.e. Tags.\<tag>) using its hex value preceded by "0x".
- Ask for a confirmation before closing a pop-up dialog with unsaved changes. - Ask for a confirmation before closing a pop-up dialog with unsaved changes.
- Better XML validation to avoid crashes caused by invalid CPE requests. - Better XML validation to avoid crashes caused by invalid CPE requests.
- Fix confusing 404 error message when the user attempts to modify a resource - Fix confusing 404 error message when the user attempts to modify a resource
when they don't have the necessary permissions. when they don't have the necessary permissions.
- Fix a rare issue where genieacs-cwmp stops accepting new connections after - Fix a rare issue where genieacs-cwmp stops accepting new connections after
running for a few weeks. running for a few weeks.
- Fix exception when IS NULL operator is used in certain situations. - Fix exception when IS NULL operator is used in certain situations.
## 1.2.2 (2020-10-03) ## 1.2.2 (2020-10-03)
@@ -24,81 +24,80 @@ running for a few weeks.
- Fix exception that can happen and persist after a Download request. - Fix exception that can happen and persist after a Download request.
- Fix validation bug preventing running refreshObject task on data model root. - Fix validation bug preventing running refreshObject task on data model root.
- Fix invalid arguments fault in refresh preset configuration when upgrading - Fix invalid arguments fault in refresh preset configuration when upgrading
from v1.1. from v1.1.
## 1.2.1 (2020-09-08) ## 1.2.1 (2020-09-08)
- Fix bug causing faults to not be displayed in the UI. - Fix bug causing faults to not be displayed in the UI.
- Fix bug where deleting objects does not get reflected immediately in the UI. - Fix bug where deleting objects does not get reflected immediately in the UI.
- Improve conversion between filters written in the expression format and - Improve conversion between filters written in the expression format and
MongoDB queries. There should now be fewer edge cases where the two are not MongoDB queries. There should now be fewer edge cases where the two are not
equisatisfiable. equisatisfiable.
## 1.2.0 (2020-09-01) ## 1.2.0 (2020-09-01)
- Support GetParameterAttributes and SetParameterAttributes TR-069 methods. - Support GetParameterAttributes and SetParameterAttributes TR-069 methods.
- Support CASE statement and COALESCE function in expressions. - Support CASE statement and COALESCE function in expressions.
- Provision arguments can now be a list of expressions that are dynamically - Provision arguments can now be a list of expressions that are dynamically
evaluated. evaluated.
- Support Forwarded HTTP header to display in the logs the correct IP of CPEs - Support Forwarded HTTP header to display in the logs the correct IP of CPEs
behind a reverse proxy. Must be configured using FORWARDED_HEADER option. behind a reverse proxy. Must be configured using FORWARDED_HEADER option.
- Config expressions can now access all available device parameters, not only - Config expressions can now access all available device parameters, not only
serial number, product class, and OUI. serial number, product class, and OUI.
- Use relative URLs throughout the UI to allow serving from a subdirectory - Use relative URLs throughout the UI to allow serving from a subdirectory using
using a reverse proxy. a reverse proxy.
- Make Date.parse() and Date.UTC() available to provision scripts. - Make Date.parse() and Date.UTC() available to provision scripts.
- libxmljs has been entirely removed in favor of our bespoke XML parser. - libxmljs has been entirely removed in favor of our bespoke XML parser.
- Removed the config option CWMP_KEEP_ALIVE_TIMEOUT. SESSION_TIMEOUT is now - Removed the config option CWMP_KEEP_ALIVE_TIMEOUT. SESSION_TIMEOUT is now used
used to determine the TCP connection timeout. to determine the TCP connection timeout.
- The all-parameters component now limits the number of parameters displayed - The all-parameters component now limits the number of parameters displayed for
for better performance. better performance.
- The process genieacs-cwmp is now much less likely to throw exceptions as a - The process genieacs-cwmp is now much less likely to throw exceptions as a
result of invalid requests from CPE. result of invalid requests from CPE.
- A large number of bug fixes and stability improvements. - A large number of bug fixes and stability improvements.
## 1.2.0-beta.0 (2019-07-30) ## 1.2.0-beta.0 (2019-07-30)
- A brand new UI superseding genieacs-gui. - A brand new UI superseding genieacs-gui.
- New initialization wizard on first run. - New initialization wizard on first run.
- New expression/query language used in search filters and preset - New expression/query language used in search filters and preset preconditions.
preconditions.
- CPE -> ACS authentication is now supported. - CPE -> ACS authentication is now supported.
- New config option (CWMP_KEEP_ALIVE_TIMEOUT) to specify how long to wait for a - New config option (CWMP_KEEP_ALIVE_TIMEOUT) to specify how long to wait for a
reply from the CPE before closing the TCP connection. reply from the CPE before closing the TCP connection.
- Debug logging has been reimplemented utilizing YAML format for logs. - Debug logging has been reimplemented utilizing YAML format for logs.
- Handle 9005 faults (Invalid Parameter Name) gracefully by attempting to - Handle 9005 faults (Invalid Parameter Name) gracefully by attempting to
rediscover the path of the missing parameter recursively. rediscover the path of the missing parameter recursively.
- declare() statements not followed by an explicit commit() are now deferred - declare() statements not followed by an explicit commit() are now deferred
until all currently active scripts have been executed. until all currently active scripts have been executed.
- FS_HOSTNAME now defaults to the server's hostname or IP. - FS_HOSTNAME now defaults to the server's hostname or IP.
- The API now validates the structure of task objects before saving. - The API now validates the structure of task objects before saving.
- New XML parser implementation for better performance. You can revert to the - New XML parser implementation for better performance. You can revert to the
old parser by enabling the config option XML_LIBXMLJS. Requires Node.js v11 or old parser by enabling the config option XML_LIBXMLJS. Requires Node.js v11 or
v10. v10.
- Performance optimizations. While performance has improved for the majority of - Performance optimizations. While performance has improved for the majority of
use cases, there may be situations where performance has degraded. It's use cases, there may be situations where performance has degraded. It's
recommended to revisit your hardware requirements. recommended to revisit your hardware requirements.
- Connection request authentication no longer uses 'auth.js' file. Instead, the - Connection request authentication no longer uses 'auth.js' file. Instead, the
connection request authentication behavior can now be customized using an connection request authentication behavior can now be customized using an
'expression'. 'expression'.
- The config file (config.json) has been deprecated. System configuration (e.g. - The config file (config.json) has been deprecated. System configuration (e.g.
listen ports, worker count) are now recommended to be passed as environment. listen ports, worker count) are now recommended to be passed as environment.
variables. Other general configuration options are stored in the database so as variables. Other general configuration options are stored in the database so
to not require service restart for changes to take effect. as to not require service restart for changes to take effect.
- Optional redis dependency has been removed completely. - Optional redis dependency has been removed completely.
- Tags now allow only alphanumeric characters and underscore. - Tags now allow only alphanumeric characters and underscore.
- Supported versions of NodeJs and MongoDB are 10.x and up and 2.6 and up - Supported versions of NodeJs and MongoDB are 10.x and up and 2.6 and up
respectively. respectively.
## 1.1.3 (2018-10-23) ## 1.1.3 (2018-10-23)
- New config option (MAX_COMMIT_ITERATIONS) to avoid max commit iterations - New config option (MAX_COMMIT_ITERATIONS) to avoid max commit iterations
faults for more complex scripts. faults for more complex scripts.
- Support base64 and hexBinary parameter types. - Support base64 and hexBinary parameter types.
- Strict parsing of number values in queries (e.g. "123abc" no longer accepted - Strict parsing of number values in queries (e.g. "123abc" no longer accepted
as 123). as 123).
- Mixing $ne and $not operators is not allowed. Now it throws an error instead - Mixing $ne and $not operators is not allowed. Now it throws an error instead
of returning incorrect results. of returning incorrect results.
- When a task expires, any associated fault is also deleted. - When a task expires, any associated fault is also deleted.
- API now accepts 'timeout' argument when posting a task. - API now accepts 'timeout' argument when posting a task.
- A number of stability fixes. - A number of stability fixes.
@@ -108,66 +107,68 @@ of returning incorrect results.
- A large number of bug fixes as well as stability and performance improvements. - A large number of bug fixes as well as stability and performance improvements.
- Three security vulnerabilities disclosed by Maximilian Hils have been patched. - Three security vulnerabilities disclosed by Maximilian Hils have been patched.
- New config option UDP_CONNECTION_REQUEST_PORT to specify binding port for UDP - New config option UDP_CONNECTION_REQUEST_PORT to specify binding port for UDP
connection requests. connection requests.
- New config option DATETIME_MILLISECONDS to strip milliseconds from dateTime - New config option DATETIME_MILLISECONDS to strip milliseconds from dateTime
values. values.
- New config option BOOLEAN_LITERAL to use 1/0 or true/false for boolean values. - New config option BOOLEAN_LITERAL to use 1/0 or true/false for boolean values.
- Parameter values that cannot be parsed according to the reported type now show - Parameter values that cannot be parsed according to the reported type now show
a warning message. a warning message.
- Virtual parameter scripts now use the variable 'args' instead of the special - Virtual parameter scripts now use the variable 'args' instead of the special
'TIMESTAMPS' and 'VALUES' variables. The content of the args array is: {declare 'TIMESTAMPS' and 'VALUES' variables. The content of the args array is:
timestamps}, {declare values}, {current timestamps}, {current values}. {declare timestamps}, {declare values}, {current timestamps}, {current
values}.
- Virtual parameter value types are now inferred from the JavaScript type if the - Virtual parameter value types are now inferred from the JavaScript type if the
returned value attribute is not a value-type pair. returned value attribute is not a value-type pair.
- Show a fault when a virtual parameter script doesn't return the required - Show a fault when a virtual parameter script doesn't return the required
attributes. attributes.
- Redis is now optional (and disabled by default), reducing the complexity of - Redis is now optional (and disabled by default), reducing the complexity of
scalable deployments. scalable deployments.
- Better detection of cyclical presets resulting in fewer faults for complex - Better detection of cyclical presets resulting in fewer faults for complex
provisioning scripts. provisioning scripts.
- Math.random() is now deterministic on per-device basis. A function has been - Math.random() is now deterministic on per-device basis. A function has been
added to allow specifying a seed value (e.g. Math.random.seed(Date.now())). added to allow specifying a seed value (e.g. Math.random.seed(Date.now())).
- Overload spikes are now handled gracefully by refusing to accept new sessions - Overload spikes are now handled gracefully by refusing to accept new sessions
temporarily when under abnormal load. temporarily when under abnormal load.
- Added log messages for session timeouts, connection drops, and XML parsing - Added log messages for session timeouts, connection drops, and XML parsing
errors. errors.
- Date.now() now takes an optional argument to specify "time steps" (in - Date.now() now takes an optional argument to specify "time steps" (in
milliseconds). This can be used to ensure a group of parameters are all milliseconds). This can be used to ensure a group of parameters are all
refreshed at the same time intervals. refreshed at the same time intervals.
- Only the non-default configuration options are now logged at process start. - Only the non-default configuration options are now logged at process start.
- Faults caused by errors from extensions now show a cleaner stack trace. - Faults caused by errors from extensions now show a cleaner stack trace.
- Exit main process if there are too many worker crashes (e.g. when DB is down). - Exit main process if there are too many worker crashes (e.g. when DB is down).
- Updated dependencies and included a lockfile to ensure installations get the - Updated dependencies and included a lockfile to ensure installations get the
exact dependencies it was tested against. exact dependencies it was tested against.
## 1.1.1 (2017-03-23) ## 1.1.1 (2017-03-23)
- Avoid crashing when connection request credentials are missing. - Avoid crashing when connection request credentials are missing.
- Show a warning instead of crashing when failing to parse parameter values - Show a warning instead of crashing when failing to parse parameter values
according to the expected value type. according to the expected value type.
- Add missing "Registered" event. - Add missing "Registered" event.
- Fix bug where in certain cases many more instances than declared are created. - Fix bug where in certain cases many more instances than declared are created.
- Fix parameter discovery bug when declared path timestamp is 1 or is not set. - Fix parameter discovery bug when declared path timestamp is 1 or is not set.
- Fix preset precondition failing when testing against datetime parameters and - Fix preset precondition failing when testing against datetime parameters and
certain other parameters like \_deviceId.\_ProductClass. certain other parameters like \_deviceId.\_ProductClass.
## 1.1.0 (2017-03-10) ## 1.1.0 (2017-03-10)
- Provisions enable implementing dynamic device configuration or complex device - Provisions enable implementing dynamic device configuration or complex device
provisioning work flow using arbitrary scripts. provisioning work flow using arbitrary scripts.
- Virtual parameters are user-defined parameters whose values are evaluated from - Virtual parameters are user-defined parameters whose values are evaluated from
a custom script. a custom script.
- Extensions are sandboxed Node.js scripts that are accessible from provision - Extensions are sandboxed Node.js scripts that are accessible from provision
and virtual parameter scripts to facilitate integration with external entities. and virtual parameter scripts to facilitate integration with external
- Support for UDP/STUN based connection requests for reaching devices behind entities.
NAT (TR-069 Annex G). - Support for UDP/STUN based connection requests for reaching devices behind NAT
(TR-069 Annex G).
- Presets can now be scheduled using a cron-like expression. - Presets can now be scheduled using a cron-like expression.
- Presets can now be tied to specific device events (e.g. boot). - Presets can now be tied to specific device events (e.g. boot).
- Presets precondition queries no longer support "$or" or other MongoDB logical - Presets precondition queries no longer support "\$or" or other MongoDB logical
operators. operators.
- Faults are no longer a part of tasks but are now first class objects. - Faults are no longer a part of tasks but are now first class objects.
- Presets are now assigned to channels. A fault in one channel only blocks - Presets are now assigned to channels. A fault in one channel only blocks
presets in that channel. presets in that channel.
- New API CRUD functions for provisions, virtual parameters, and faults. - New API CRUD functions for provisions, virtual parameters, and faults.
- New config options for XML output. - New config options for XML output.
- API responses now include "GenieACS-Version" header. - API responses now include "GenieACS-Version" header.
@@ -176,19 +177,19 @@ presets in that channel.
- Supported Node.js versions are 6.x and 7.x. - Supported Node.js versions are 6.x and 7.x.
- Supported MongoDB versions are 2.6 through 3.4. - Supported MongoDB versions are 2.6 through 3.4.
- Expect performance differences due to major under the hood changes. Some - Expect performance differences due to major under the hood changes. Some
operations are faster and some are slower. Overall performance is improved. operations are faster and some are slower. Overall performance is improved.
- GenieACS will no longer fetch the entire device data model upon first contact - GenieACS will no longer fetch the entire device data model upon first contact
but will instead only fetch the parameters it needs to fulfill the presets. but will instead only fetch the parameters it needs to fulfill the presets.
- Logs have been overhauled and split into two streams: process log (stderr) and - Logs have been overhauled and split into two streams: process log (stderr) and
access log (stdout). Also added config options to dump logs to files rather than access log (stdout). Also added config options to dump logs to files rather
standard streams. than standard streams.
- Connection request authentication credentials are picked up from the device - Connection request authentication credentials are picked up from the device
data model if available. config/auth.js is still supported as a fallback and now data model if available. config/auth.js is still supported as a fallback and
supports an optional callback argument. now supports an optional callback argument.
- Custom commands have been removed. Use virtual parameters and/or extensions. - Custom commands have been removed. Use virtual parameters and/or extensions.
- Aliases and value normalizers (config/parameters.json) have been removed. Use - Aliases and value normalizers (config/parameters.json) have been removed. Use
virtual parameters. virtual parameters.
- The API /devices/<device_id>/preset has been removed. - The API /devices/<device_id>/preset has been removed.
- Rarely used RequestDownload method no longer supported. - Rarely used RequestDownload method no longer supported.
- The TR-069 client simulator has moved to its own repo at - The TR-069 client simulator has moved to its own repo at
https://github.com/zaidka/genieacs-sim https://github.com/zaidka/genieacs-sim
+10 -9
View File
@@ -5,8 +5,8 @@ tracker is strictly for bug reports.
# Issues # Issues
We use GitHub issues to track bugs. Please ensure your bug description is We use GitHub issues to track bugs. Please ensure your bug description is clear
clear and has sufficient instructions to be able to reproduce the issue. and has sufficient instructions to be able to reproduce the issue.
If you face interoperability issues with your CPE, more often than not it's a If you face interoperability issues with your CPE, more often than not it's a
device related issue. Please consult the [forum] before submitting an Issue. device related issue. Please consult the [forum] before submitting an Issue.
@@ -26,13 +26,14 @@ By submitting a pull request to this repository, you acknowledge that, while
maintaining copyright, you grant Zaid Abdulla a perpetual, worldwide, non- maintaining copyright, you grant Zaid Abdulla a perpetual, worldwide, non-
exclusive, no-charge, royalty-free, irrevocable license to reproduce, prepare exclusive, no-charge, royalty-free, irrevocable license to reproduce, prepare
derivative works of, publicly display, publicly perform, sublicense, and derivative works of, publicly display, publicly perform, sublicense, and
distribute your contributions and such derivative works under the AGPLv3 distribute your contributions and such derivative works under the AGPLv3 license
license or any other license terms, including, but not limited to, proprietary or any other license terms, including, but not limited to, proprietary or
or commercial license terms. commercial license terms.
You confirm that you own or have rights to distribute and sublicense the You confirm that you own or have rights to distribute and sublicense the source
source code contained therein, and that your content does not infringe upon code contained therein, and that your content does not infringe upon the
the intellectual property rights of a third party. intellectual property rights of a third party.
[commit-guidelines]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html [commit-guidelines]:
http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[forum]: https://forum.genieacs.com [forum]: https://forum.genieacs.com
+8 -9
View File
@@ -20,7 +20,7 @@ Install GenieACS from NPM:
sudo npm install -g --unsafe-perm genieacs sudo npm install -g --unsafe-perm genieacs
To build from source instead, clone this repo or download the source archive To build from source instead, clone this repo or download the source archive
then *cd* into the source directory then run: then _cd_ into the source directory then run:
npm install npm install
npm run build npm run build
@@ -30,8 +30,8 @@ source):
### genieacs-cwmp ### genieacs-cwmp
This is the service that the CPEs will communicate with. It listens on port This is the service that the CPEs will communicate with. It listens on port 7547
7547 by default. Configure the ACS URL in your devices accordingly. by default. Configure the ACS URL in your devices accordingly.
You may optionally use [genieacs-sim](https://github.com/genieacs/genieacs-sim) You may optionally use [genieacs-sim](https://github.com/genieacs/genieacs-sim)
as a dummy TR-069 simulator if you don't have a CPE at hand. as a dummy TR-069 simulator if you don't have a CPE at hand.
@@ -50,7 +50,7 @@ such. It listens on port 7567 by default.
### genieacs-ui ### genieacs-ui
This serves the web based user interface. It listens on port 3000 by default. This serves the web based user interface. It listens on port 3000 by default.
You must pass *--ui-jwt-secret* argument to supply the secret key used for You must pass _--ui-jwt-secret_ argument to supply the secret key used for
signing browser cookies: signing browser cookies:
genieacs-ui --ui-jwt-secret secret genieacs-ui --ui-jwt-secret secret
@@ -64,14 +64,13 @@ a complete installation guide for production deployments.
## Support ## Support
The [forum](https://forum.genieacs.com) is a good place to get guidance and The [forum](https://forum.genieacs.com) is a good place to get guidance and help
help from the community. Head on over and join the conversation! from the community. Head on over and join the conversation!
For commercial support options, please visit For commercial support options, please visit
[genieacs.com](https://genieacs.com/support/). [genieacs.com](https://genieacs.com/support/).
## License ## License
Copyright 2013-2020 GenieACS Inc. GenieACS is released under the [AGPLv3 Copyright 2013-2020 GenieACS Inc. GenieACS is released under the
license [AGPLv3 license terms](https://raw.githubusercontent.com/genieacs/genieacs/master/LICENSE).
terms](https://raw.githubusercontent.com/genieacs/genieacs/master/LICENSE).
+2 -3
View File
@@ -1,5 +1,4 @@
export default { export default {
"extensions": ["ts"], extensions: ["ts"],
"require": ["esm", "ts-node/register/transpile-only"] require: ["esm", "ts-node/register/transpile-only"],
}; };
+18 -15
View File
@@ -10,25 +10,28 @@ let cache = null;
let cacheExpire = 0; let cacheExpire = 0;
function latlong(args, callback) { function latlong(args, callback) {
if (Date.now() < cacheExpire) if (Date.now() < cacheExpire) return callback(null, cache);
return callback(null, cache);
http.get("http://api.open-notify.org/iss-now.json", (res) => { http
if (res.statusCode !== 200) .get("http://api.open-notify.org/iss-now.json", (res) => {
return callback(new Error(`Request failed (status code: ${res.statusCode})`)); if (res.statusCode !== 200)
return callback(
new Error(`Request failed (status code: ${res.statusCode})`)
);
let rawData = ""; let rawData = "";
res.on("data", (chunk) => rawData += chunk); res.on("data", (chunk) => (rawData += chunk));
res.on("end", () => { res.on("end", () => {
let pos = JSON.parse(rawData)["iss_position"]; let pos = JSON.parse(rawData)["iss_position"];
cache = [+pos["latitude"], +pos["longitude"]]; cache = [+pos["latitude"], +pos["longitude"]];
cacheExpire = Date.now() + 10000; cacheExpire = Date.now() + 10000;
callback(null, cache); callback(null, cache);
});
})
.on("error", (err) => {
callback(err);
}); });
}).on("error", (err) => {
callback(err);
});
} }
exports.latlong = latlong; exports.latlong = latlong;
+1 -1
View File
@@ -80,7 +80,7 @@
"scripts": { "scripts": {
"test": "ava --verbose --color", "test": "ava --verbose --color",
"lint-eslint": "eslint --fix \"bin/*.ts\" \"lib/**/*.ts\" \"ui/**/*.ts\" \"test/**/*.ts\" \"build/**/*.ts\" \"tools/*.ts\"", "lint-eslint": "eslint --fix \"bin/*.ts\" \"lib/**/*.ts\" \"ui/**/*.ts\" \"test/**/*.ts\" \"build/**/*.ts\" \"tools/*.ts\"",
"lint-prettier": "prettier --parser typescript --write \"bin/**/*.ts\" \"lib/**/*.ts\" \"ui/**/*.ts\" \"test/**/*.ts\" \"build/**/*.ts\" \"tools/**/*.ts\"", "lint-prettier": "prettier --prose-wrap always --write .",
"lint-tsc": "tsc --noEmit", "lint-tsc": "tsc --noEmit",
"lint": "npm run lint-eslint && npm run lint-prettier && npm run lint-tsc", "lint": "npm run lint-eslint && npm run lint-prettier && npm run lint-tsc",
"build": "node -r esm -r ts-node/register/transpile-only build/build" "build": "node -r esm -r ts-node/register/transpile-only build/build"
+7 -9
View File
@@ -1,8 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": [ "lib": ["esnext", "dom"],
"esnext", "dom"
],
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"target": "esnext", "target": "esnext",
@@ -14,11 +12,11 @@
"allowJs": true "allowJs": true
}, },
"include": [ "include": [
"./bin/*.ts", "./bin/*.ts",
"./lib/**/*", "./lib/**/*",
"./ui/**/*", "./ui/**/*",
"./test/**/*", "./test/**/*",
"./build/**/*", "./build/**/*",
"./tools/*.ts" "./tools/*.ts"
] ]
} }