Skip to content

posconnetwork/JS-Data-Retrieval-Sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

POSCON JavaScript Automated Data Retrieval

Welcome! If you're reading this page, you probably want to program your own data retrieval software to be used by the POSCON. This can be used to:

  • Pull ATIS information, METAR, TAF, and/or SIGMET from live sources
  • Generate an ATIS, METAR, TAF, and/or SIGMET automatically

Table of Contents

Architecture

All user-supplied JavaScript for the purpose of retriving an ATIS is run in a v8 Isolate. What does that mean? It means your code is being run in an isolated process, with no access to the host machine. We use this to ensure that no code supplied by other users may intefere with yours.

There may only be one file provided per FIR, which must contain all code for retrieval for any airports within the FIR. Unsafe functions, modules, and objects are also disabled, such as process, eval, and fs.

Recommended Development Environment

Our servers use Node v14 on an Alpine image, and store scripts on a remote location.

Interface

Your script must export a default function that returns AerodromeInformation or a Promise that completes with one.

export default function(icao: string): AerodromeInformation | PromiseLike<AerodromeInformation> { ... }

Please refer to spec.d.ts for details. When compiled to CommonJS, it becomes the following:

exports.default = function(icao) { ... }

Allowed Modules

The following modules are currently allowed to be import'ed by a script:

If you would like a module added that is not currently available, please open an issue with the title Request to add <module name>, and the body containing a brief description of how the module would be used, and justification for its inclusion.

Sample Code

The sample code in VHHK.ts will retrieve information for Hong Kong International Airport (VHHH) in VHHK FIR written in TypeScript. A CommonJS implementation is available in VHHK_CommonJS.js

The sample code in TypeScript embeds type annotations for easy understanding as well as context-aware code completion in popular IDEs. Run npm run build to build a CommonJS file from TypeScript. You can also write in CommonJS directly.

VABF.ts is an advanced sample involving an append-only cookie jar and session reuse.

How do I test locally?

Run npm install to install dependencies for testing, and then use the test script as below.

CommonJS

To test VHHK_CommonJS.js with station VHHH, run npm run test-js ./VHHK_CommonJS VHHH.

TypeScript

To test VHHK.ts with station VHHH, run npm test ./VHHK VHHH.

To test VABF.ts with stations VAAH, VEAT, VIAR, and VOBL, run npm test ./VABF VAAH VEAT VIAR VOBL.

I'm done, now what?

There are a few requirements for your file. They are as such:

  • It must be named YOUR-FIR.js (it cannot be TypeScript, it must be compiled)
    • I.e., if you are writing a file to be used by the VHHK FIR, it would be named VHHK.js
  • The default export must be a function that returns either:
    • AerodromeInformation, as defined in spec.d.ts
    • A promise that resolves to AerodromeInformation
  • All unused or unknown fields must be blank values
  • Only ONE of these two may be populated with anything other than an empty value:
    • ATIS body
    • ATIS departure and arrival

My script adheres to the above, and I'm ready for it to be used

Once you've written your script, please send it to support@poscon.net to be integrated.

Questions? Comments? Concerns?

If you have any questions about the library, please feel free to open an issue, or send us a message at support@poscon.net

Credits

  • Server software by Eamonn Nugent (@space55)
  • Client side TypeScript, documentation assistance, and testing by Tim Wong (@wegylexy)

About

POSCON JavaScript data retrieval sample code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •