The Starships API is a simple Node.js server built using Express, Axios, and CORS. It fetches data from the Star Wars API (SWAPI) and allows users to query and sort Star Wars starships based on various properties.
- Fetch Star Wars starships data from the SWAPI.
- Sort starships by various properties, including name, model, manufacturer, cost, length, and more.
- Support for both ascending and descending sorting.
- Node.js (>= v14.x.x)
- npm (>= v6.x.x)
-
Clone the repository:
git clone https://github.com/abgnydn/test1.git
-
Change to the project directory: cd test1
-
Install the dependencies: npm install
To start the server, run:
npm start
The server will be running on http://localhost:3000
.
GET /starships?sort_by=<property>&order=<order>
Query Parameters:
-
sort_by
(optional): The property to sort the starships by. Available options are:name
model
manufacturer
cost_in_credits
length
max_atmosphering_speed
crew
passengers
cargo_capacity
consumables
hyperdrive_rating
MGLT
starship_class
Default value isname
.
-
order
(optional): The sorting order. Available options are:asc
(ascending)desc
(descending) Default value isasc
.
Example:
GET /starships?sort_by=length&order=desc
This request will return a list of Star Wars starships sorted by length in descending order.
To run the test suite, execute: npm test
This project is open-source and available under the MIT License.