Mock flight data delivered simply and quickly without a database.
First, make sure you have Node.js and npm then install project dependencies by running
After dependencies have been installed, run
npm run dev, which will perform the following actions:
srcfor changes, and transpile into
distagain after observed changes
distfor changes and restart the application after observed changes
Once the app has started, try hitting
3030 is the default port unless overridden from
.env) from a browser.
In order to keep the app lightweight and eliminate the need for a database, this project uses seed randomization (credit to @JohnKahn for the amazing idea!). If you don't care about the way data is generated, just read the first two bullets below and skip the rest.
Here are some important things to note if you plan to modify the random data generation:
Generatoris initialized with a
randommethod will generate random data each time it is called, however, this data generation is deterministic...
randomfor a given seed will always be the same
generatorBand each have been initialized with a seed value of
RANDOMIZATION_IS_COOL!. If we call the
randommethod of each generator (e.g.,
B1), the result will be the same (
A1 === B1). If, however, we call the
randommethod again, the new values will again be the same (
A2 === B2) but they should differ from the first set of values generated by each of the generators (
A1 !== A2 && B1 !== B2).
GET /flightscall is performed, the app generates all flights for the specified
date, regardless of the presence of
/flights?date=2020-01-01&origin=DFWwould differ). Here's an example:
randommethod calls 1-10 with a seed of
2020-01-01will ALWAYS result in:
[1, 7, 9, 1, 8, 4, 5, 7, 2, 3]
randomcalls 8-10), flight
123was call 9 and got a random value of
randomcalls 1-3), flight
123was call 2 and got a random value of
The src/DataCollection folder contains tools and data to augment the airport options. The
parse_csv.py script takes the airports in
airports.json and compares them with the Wikipedia page for American Airlines destinations. Only airports with American Airlines flights are included.
This data can be customized by changing the constants at the top of
ALLOWED_COUNTRIES list is the countries that airports can be in -- currently, this is set to only grab data from the United States. The
MIN_DIRECT_FLIGHTS_PER_DAY is another way to narrow down the data by selecting only larger airports. The current value for this is 10, meaning that only airports that have more than 10 direct flights per day there are included.
This script is set up to produce output in the correct format for the typescript file
airports.ts. When the script is run, the airports in that file are updated.
The python script uses the
wikipedia package, a package for retrieving and parsing Wikipedia pages. Before the script can run, this package must be installed with
pip install wikipedia
This project utilizes framework uses Facebook's Jest framework for testing. Jest is based on the
Jasmine framework. While some developers prefer
Mocha, we've chosen to fully adopt
Jest on top of
Jasmine as-is until a significant need requires an alternative solution.
Writing a test is as simple as creating a
*.test.ts file in the
./src directory along with an associated
npm run test to run tests.
Additional testing scripts:
test: runs all tests
test:changed: runs tests related to uncommited git changes only
Interested in contributing to the project? Check out our Contributing Guidelines.