Welcome! I really appreciate that you checked out the contributing guide. This means you are thinking of contributing to this project. Well, you are at the right place.
Before you start contributing to any project it is important to understand the folder structure for that project. For this project, the details are as follows:
1) data
- This folder contains the data related to all the languages. This is where the actual shayari and quotes reside.
- for [adding a new language data](#adding-data) make a new folder inside the `data` folder as `data/${Your_Language_Name}`.
- add the data file inside the folder as `data/${Your_Language_Name}/data.js`.
- NOTE: name the data file as 'data.js' only.
- then [update the database](#updating-the-database) `quotes.db`, an sqlite3 database.
2) data_endpoints
- This folder contains the retriever or the filetered quotes function. It return the filtered data for the language specified. It’s usecase can be viewed in the routes/route.js
file.
- there is a single file, filter.js
, DO NOT CHANGE ANYTHING IN THIS FILE
3) routes
- This folder contains all the routes the API provides. It has a single file route.js
(DO NOT CHANGE ANYTHING IN THIS FILE) which has all the routes, which are mainly:
- */:language_name* -> returns all of the data for the language if no range is provided.
- */:language_name?min=value&max=value* -> returns the data in the specified range of min and max.
- */:language_name/random* -> returns a single random data from the language specified.
4) languages.js
- contains an array of all the languages for which the data exists.
5) index.js
- the entry point to this project, DO NOT CHANGE ANYTHING IN THIS FILE.
6) db.js
- the file is used to update the database, anytime a new language is added to the API.
For installation and local setup, follow these steps:
Fork this repository.
Clone the forked repository.
git clone https://github.com/your_username/farzi-vichar-api
Run the following command to start your local server
npm install
npm start
Create a working branch and start making your changes.
git checkout -b your-new-branch-name
Commit your changes. Make sure to add a descriptive commit message.
git commit -m "your_message"
When you’re finished with the changes, create a pull request, also known as a PR.
data
directory.data
directory, (follow the pattern of already made directories) as:
data/Your_Language_Name
data/Your_Language_Name/data.js
create an array: const your_language_name_data_array = []
, which will be an array of objects. After adding the data export the array using export default your_language_name_data_array
.
const example_data_array = [
{
id: 1,
content:
"",
author: "",
category: "",
likes: 0,
views: 0,
ispublished: false,
isedited: false,
isfeatured: false,
link: "",
}
];
export default example_data_array;
For adding data to database, open the db.js
file, follow in-file instructions:
user_data_array
variableyour_language_name_quotes
db.js
file using node
, receiving output as: your_language_name data was added successfully.
node db.js
or
node .\db.js
or
node ./db.js
// OUTPUT on console: "your_language_name data was added successfully."
If you are a beginner, I would recommend you to use VS Code. Also, see this.
main
branch. Always create a new branch and then start making changes.
git push -u origin <branch>