Mock flight data delivered simply and quickly without a database.
Once the app is running, you should see a 👋 emoji if you hit the root of the app (e.g.,
localhost:3030). In order to retrieve flight information, make a
GET request to
/flights with a
date query paramter and a date value with the following format:
YYYY-MM-DD. For example,
your-app.herokuapp.com/flights?date=2020-01-01 will return flight details for January 1st, 2020. If you'd like to specify an origin or a destination, use the
destination query parameters with an airport code as the value; for example,
your-app.herokuapp.com/flights?date=2020-01-01&origin=DFW&destination=LGA will retrieve flights from DFW to LGA on 1/1/2020.
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
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.