This project is a Node.js API server built with Express. It provides endpoints to interact with dummy JSON data, including functionalities for filtering, sorting, and retrieving data.
- Fetch dummy JSON data
- Filter data by multiple fields
- Sort data by multiple fields
- Node.js (v14 or higher)
- npm (Node Package Manager)
- Installation
- Running the project locally
- Testing the API
- Postman Documentation
- API Endpoints
- Examples
-
Clone the Repository
git clone https://github.com/Shreshthaaa/Rocketium.git
-
Navigate to the Project Directory
cd your-repo-name -
Install Dependencies
First, install the project dependencies defined in
package.json.npm install
Then, install
expressandaxiosif they are not already listed inpackage.json.npm install express axios
-
Verify Installation
Check that express and axios are listed in your package.json file under dependencies:
"dependencies": { "express": "^x.x.x", "axios": "^x.x.x" }
-
Start the Server
The server will run on http://localhost:3000.
npm start
-
Access the API
- GET
/: Fetch all data - GET
/?id=<id>: Filter by id - GET
/?name=<name>: Filter by name - GET
/?language=<language>: Filter by language - GET
/?name=<name>&sortBy=<field>,<field>&sortOrder=<asc|desc>: Filter by multiple fields and sort - GET
/?sortBy=<field>&sortOrder=<asc|desc>: Sort by specified field and order - GET
/?sortBy=<field>,<field>&sortOrder=<asc|desc>: Sort by multiple fields
You can use Postman to test the API endpoints. Here’s how:
- Open Postman and create a new request.
- Set the Request Type to
GET. - Enter the URL:
http://localhost:3000/. - Add Query Parameters for filtering and sorting, if needed.
- Click "Send" to see the response.
For a detailed guide on how to use the API, including examples and additional functionalities, refer to this comprehensive Postman Documentation.
- Endpoint:
/ - Method:
GET - Query Parameters:
- Filtering: Filter by any field in the data. For example:
?name=<name>- Filters by name?language=<language>- Filters by language?name=<name>&language=<language>- Filters by multiple fields
- Sorting: Sort by one or more fields. For example:
?sortBy=<field>- Sorts by a particular field?sortBy=<field>,<field>- Sorts by multiple fields?sortBy=<field>,<field>&sortOrder=<asc|desc>- Sorts by multiple fields and any order
- Filtering: Filter by any field in the data. For example:
-
Fetch all data:
GET http://localhost:3000/
-
Filter by
id:GET http://localhost:3000/?id=V59OF92YF627HFY0 -
Filter by
name:GET http://localhost:3000/?name=Adeel -
Sort by
namein ascending order:GET http://localhost:3000/?sortBy=name&sortOrder=asc
-
Filter by multiple fields and sort:
GET http://localhost:3000/?name=Adeel&sortBy=name,version&sortOrder=desc
-
Sort by multiple fields:
GET http://localhost:3000/?sortBy=name,version&sortOrder=asc
-
Filter by a particular
language:GET http://localhost:3000/?language=Sindhi -
Sort by
versionin ascending orderGET http://localhost:3000/?sortBy=version&sortOrder=asc
Feel free to fork the repository and submit pull requests. For any issues or feature requests, please open an issue on the GitHub repository.