Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4.0.0] #51

Merged
merged 89 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c947bb3
Added so many new stuff
kyrea Aug 6, 2023
62fc0c3
Added a quick fix
kyrea Aug 6, 2023
ab0f9a8
Uncommented some stuff
kyrea Aug 6, 2023
693b0c8
Some more hot fixes
kyrea Aug 6, 2023
bf61295
Added somemore stuff new
kyrea Aug 7, 2023
ac8c374
Added builds
kyrea Aug 7, 2023
fa34f94
Added gitignore
kyrea Aug 7, 2023
b42347c
Removed build
kyrea Aug 7, 2023
e4ef464
Removed output
kyrea Aug 7, 2023
f9f04fc
removed out
kyrea Aug 7, 2023
6741688
Removed the website as we moved to other repository
kyrea Aug 7, 2023
162e0f3
Updated the package
kyrea Aug 7, 2023
e1bbcd6
Removed nextjs
kyrea Aug 7, 2023
63eb2b5
Changed all the endpoints
kyrea Aug 7, 2023
cce1e2e
New users will now respond with the latest token
kyrea Aug 7, 2023
0fb35af
Fix for database query built from user-controlled sources
kyrea Aug 8, 2023
d947c04
Fixed missing rate limiting
kyrea Aug 8, 2023
d04b2a6
Add detailed comments and documentation for API endpoints and user au…
kyrea Aug 8, 2023
edee687
Added Github Sponsor
kyrea Aug 8, 2023
d203b60
Refactor: Update API code to ES6 from CommonJS
kyrea Dec 9, 2023
f5edd38
Updated the base endpoint response
kyrea Dec 9, 2023
ec8cb28
Update prettier.config.js based on latest JavaScript standards
kyrea Dec 11, 2023
6b2b99a
Refactor authentication middleware for clarity and modularity
kyrea Dec 11, 2023
994a2d0
Refactored the user schema to include a comprehensive status_history …
kyrea Dec 11, 2023
4e5fdd7
Refactor rate limiter middleware for clarity and error handling
kyrea Dec 11, 2023
0d31af2
Refactored authorization and added rate-limit functions to endpoints
kyrea Dec 11, 2023
0cd0660
Revamped the codes
kyrea Dec 19, 2023
56f75c9
Moved the routes and controllers separately to different version folders
kyrea Dec 19, 2023
bb23d80
Changed config.js directory
kyrea Dec 27, 2023
d1337eb
Added better documentation for rateLimit
kyrea Dec 27, 2023
3692935
Added rateLimit to fact endpoints
kyrea Dec 27, 2023
bd24de8
Changed directories with different naming
kyrea Dec 27, 2023
951d08e
Renamed facts.js to fact.js
kyrea Dec 27, 2023
f348b0d
Improved routes index.js code with better documentation
kyrea Dec 27, 2023
0ee666b
Added rateLimit
kyrea Dec 27, 2023
9928267
Added fix to the security vulnerbility
kyrea Dec 27, 2023
e871af0
Fixed the code base to work accordingly
kyrea Dec 27, 2023
02fd9ac
Renamed files and removed extra spaces
kyrea Dec 27, 2023
8981089
Renamed the file
kyrea Dec 27, 2023
6450489
Fixed some imports
kyrea Dec 27, 2023
359dbac
Changed version to 4.x.x
kyrea Dec 27, 2023
b613a08
Added a response for versions
kyrea Dec 27, 2023
fa10de4
Some adjustment to make custom ratelimit work
kyrea Dec 27, 2023
f5f041d
Change user controller directory
kyrea Dec 27, 2023
58639e5
Improved the readme and contribution guidelines (further changes mayb…
kyrea Dec 27, 2023
e9f3786
Removed nixpacks as it was neccessary
kyrea Dec 27, 2023
24e0bdb
Update some packages
kyrea Dec 27, 2023
1b2f14e
Changed the database middlewares directory and improvements
kyrea Dec 29, 2023
48435c1
Better documentation
kyrea Dec 29, 2023
ad6a38f
Removed version from comment, and added all reqest types
kyrea Dec 29, 2023
485ea82
Renamed Quotes.js to Quote.js
kyrea Jan 4, 2024
22702ea
Fixed the parseOrder import
kyrea Jan 4, 2024
f3bf674
Fixed typo in the main function
kyrea Jan 4, 2024
f8fe9ea
Added better documentation
kyrea Jan 4, 2024
0140142
Updated the imports
kyrea Jan 4, 2024
8bf9698
Fixed typo in the main function
kyrea Jan 4, 2024
312b2ad
Fixed typo in the main function
kyrea Jan 4, 2024
9b7b6a9
Removed unnessary comment
kyrea Jan 4, 2024
260dec7
Added New Endpoints: /listTags, /password, /uvuify, /uwuify, /owoify,…
kyrea Jan 4, 2024
dea5017
Updated imports
kyrea Jan 4, 2024
891d39b
Renamed files and updated imports
kyrea Jan 4, 2024
f94df44
Added /waifu route
kyrea Jan 4, 2024
d37a02c
Updated models documentation
kyrea Jan 4, 2024
666e7b6
Improved the documentation
kyrea Jan 4, 2024
109caf1
Improved comments and added new .env.example
kyrea Jan 4, 2024
6e241a8
Improvements
kyrea Jan 4, 2024
7f565fd
Fixed ratelimit issue
kyrea Jan 4, 2024
80a439c
Added a fix
kyrea Jan 4, 2024
45c1ff8
Added v3 routes
kyrea Jan 4, 2024
bc10f32
Added a way to store access_token
kyrea Jan 5, 2024
ca3a4be
Added an endpoint to fetch user details
kyrea Jan 5, 2024
b535c92
Added a fix to the null response error
kyrea Jan 5, 2024
131f317
Removed console logs
kyrea Jan 5, 2024
420c0c3
Changed default req_limit and exchausted message
kyrea Jan 6, 2024
96434ed
Fixed quoto typo to quota
kyrea Jan 6, 2024
41e1bf8
Added a fix to header
kyrea Jan 6, 2024
4fb6465
Removed unncessary values
kyrea Jan 6, 2024
68e4b2d
Improved routes index
kyrea Jan 6, 2024
7bcf278
Add all interaction routes
kyrea Jan 6, 2024
9f2b187
Improved the documentation and renamed the function
kyrea Jan 8, 2024
430ee2a
Renamed the functions
kyrea Jan 8, 2024
72b3670
Renamed the function to getQuote
kyrea Jan 8, 2024
48288c4
Added query filter using character name or anime
kyrea Jan 8, 2024
bd61419
Added sanitization function before using RegEx
kyrea Jan 8, 2024
3b50859
Removed token reset
kyrea Jan 9, 2024
08845a5
Added a check if the user exists for updating token
kyrea Jan 9, 2024
b957d8c
Added a way to reset the token of user upon leaving the server
kyrea Jan 9, 2024
2dd550b
Added a patch route to reset token
kyrea Jan 10, 2024
7784343
Updated packages
kyrea Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
43 changes: 33 additions & 10 deletions .env_example
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
## Create a file name with .env, then copy this file and paste over there and fill the details.

# Get the Mongodb URL from their site
MONGODB_URI=
# Your PORT for the API to work on
PORT=
# Node Environment [ production or development ], use development to log errors.
NODE_ENV=
# Creates Log
DISCORD_WEBHOOK_URL=
# Example .env file for configuring environment variables

# MongoDB connection URI

MONGODB_URI= # Specify the URI for MongoDB connection

# Port for the server

PORT= # Define the server port

# Node environment ('development', 'production', etc.)

NODE_ENV= # Set the Node environment

# Logger configuration ('true' or 'false')

LOGGER= # Enable or disable the logger

# Webhook URL for chatbot logger

CHATBOT_LOGGER_WEBHOOK= # Provide the URL for the chatbot logger webhook

# Discord webhook URL

DISCORD_WEBHOOK_URL= # Input the URL for Discord webhook

# Access key for authentication

ACCESS_KEY= # Assign the access key for authentication

# HMAC key for generating secure tokens

HMAC_KEY= # Set the HMAC key for secure token generation
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ko_fi: Aeryk
github: kyrea
16 changes: 7 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# Environment variables
# Ignore environment variables file
.env


# dependencies
# Ignore dependencies
/node_modules

# Private files
# Ignore private files
/private


# jetbrains
# JetBrains IDE files
.idea/

# vscode
# Visual Studio Code settings
.vscode/

# Logs
# Ignore log files
/logs

# Data Files
# Ignore data files
/data
16 changes: 8 additions & 8 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"useTabs": false,
"tabWidth": 2,
"semi": false,
"trailingComma": "es5",
"proseWrap": "preserve",
"printWidth": 80,
"semi": true,
"singleQuote": true,
"arrowParens": "avoid",
"singleQuote": true
}
"trailingComma": "all",
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"proseWrap": "preserve"
}
85 changes: 48 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,81 @@
# Contributing to Waifu.it
# 🌟 Your Contribution Matters at Waifu.it! 🌟

We love your input! We want to make contributing to this project as easy as possible, whether it's:
Greetings, and a heartfelt thank you for considering becoming a part of the Waifu.it project! We're thrilled about the prospect of your contribution and have made the process a breeze. Whether you're fixing something, reporting an issue, joining us as a maintainer, suggesting fantastic new features, or just engaging in lively discussions about our code, here's your invitation to dive in:

- Submitting a fix
- Reporting an issue
- Becoming a maintainer
- Proposing new features
- Discussing the current state of the code
## Embrace our Code of Conduct

## Code of Conduct
Before you embark on your journey, take a moment to acquaint yourself with our [Code of Conduct](CODE_OF_CONDUCT.md). It's the cornerstone of our respectful and inclusive community.

The code of conduct is described in [Code of Conduct](CODE_OF_CONDUCT.md).
## FAQs - Your Shortcut to Wisdom 🧠

## Frequently Asked Questions (FAQs)
To make your initiation smoother, we've compiled a list of Frequently Asked Questions:

<!--- I thought it would be great to have a list of FAQs for the project to help save time for new contributors--->
- **Q:** [The Question?]
- **A:** [The Answer!]

- Q: [The Question?]
- A: [The Answer!]
## Dreaming Up Features? 🚀

## Feature Request
Crafting a Feature Request? Elevate it with:

Great Feature Requests tend to have:
- A snappy summary of your brilliant idea.
- Unveil the why behind your feature vision.
- Sprinkle in some extra context—images, resource links—to paint the full picture.

- A quick idea summary.
- What & why you wanted to add the specific feature.
- Additional context like images, links to resources to implement the feature etc, etc.
## Join Our Dance of Development 💃🕺

## Development Process
Pull requests are your golden ticket to propose changes! Directly submit your pull requests [here](https://github.com/WaifuAPI/Waifu.it/pulls). After a bit of magic in the review, your changes can become part of our enchanting project.

Pull requests are the best way to propose changes. We actively welcome your pull requests and invite you to submit pull requests directly <a href="https://github.com/WaifuAPI/Waifu.it/pulls">here</a>, and after review, these can be merged into the project.
## Crafting Pull Requests - Unleash Your Magic ✨

## Pull Requests
1. Fork the repo and weave your code into the `staging` branch.
2. If your code is a performer, let it showcase with some test examples.
3. Describe your pull request with the elegance it deserves.

1. Fork the repo and pr to `staging` branch only.
2. If you've added code that should be tested, add some test examples.
3. Ensure to describe your pull request.
## Issues - Illuminate the Path 🕯️

## Issues
When reporting issues, cast a clear light with your description. Show us how to find the bug by [opening a new issue](https://github.com/WaifuAPI/Waifu.it/issues); it's as simple as that!

Please ensure your description is
clear and has sufficient instructions to be able to reproduce the issue. Report a bug by <a href="https://github.com/WaifuAPI/Waifu.it/issues">opening a new issue</a>; it's that easy!

## Running the API Locally
## Magic Happens Locally - Run the API 🎩🐇

**Requirements**

- Node >= 12.x
- Node.js >=18.x
- MongoDB

**1. Create a database**
**1. Create a Database**

Create a MongoDB database.
Craft a MongoDB database. No worries if you don't have MongoDB locally; [MongoDB Atlas](https://www.mongodb.com/cloud/atlas) has a free hosted database waiting for you.

If you don't have MongoDB setup locally, then you can use [MongoDB Atlas][mongodb/atlas] to create a free hosted database.
**2. Enchant with Environment Variables**

**2. Environment Variables**
Craft a `.env` file in the project's magical realm. Copy the contents from `.env_example` and replace `<your-database-uri>` with your database connection string. Other mystical environment variables are revealed in the file.

You need to set the `MONGODB_URI` environment variable to point to your database.
```shell
MONGODB_URI=<your-mongodb-uri>
```

Create a file called `.env` in the root directory of the project. Copy everything from `.env_example` and replace `<your-database-uri>` with the connection string for your database, _other env variables info are commented in the file itself._
**3. Cast the Spell of Dependencies**

```shell
MONGODB_URI=<your-mongodb-uri>
$ npm install
```

**4. Begin the Incantation - Start the Server**

The server dances to your tune, restarting gracefully with every code change.

```shell
$ npm run dev
```

**And there you have it!**

## License - Let's Create a Masterpiece Together 🎨

By contributing to Waifu.it, you're authoring a chapter in our story. Your contributions will be elegantly licensed under the terms specified in the [LICENSE file](LICENSE.md).

Let the adventure begin! Explore the realms of Waifu.it, and let's co-create something truly magical! 🚀✨

**3. Installing dependencies**

```shell
Expand Down
2 changes: 1 addition & 1 deletion DOCS.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## [Click here](https://github.com/WaifuAPI/Documentation) for API Documentaion.
## [Click here](https://docs.waifu.it) for API Documentaion.
64 changes: 24 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
## Announcements
## 🚀 Exciting News!

###### 🕛 23 May, 2023
### 📢 Migration from Private to Public
This repository will continue being as open-source while strictly following the [LICENCE](LICENCE.md).
### 📅 May 23, 2023

###### 🕛 01 Feb, 2022
### ~~📢 Migration from Public to Private~~
~~This repository will no longer be updated with the latest versions of code. Our hosted version of this API, [__Waifu.it__](https://waifu.it/) **does not run the code in this repository anymore**. The official API's source code has been made private. We will still maintain this repository over time with patches and so but it will depend on the circumstances. And we will only be providing limited, non-obligatory support to self-hosting users **who have not made changes to the code we deem to be significant**.~~
We're thrilled to announce a major transformation! Our repository is now fully open-source, embracing a new era of collaboration. Dive into the code, explore its possibilities, and contribute to the future of this amazing project. All within the bounds of our [LICENSE](LICENCE.md).

---

<div align="center">

<h1 align="center">Waifu.it</h1>
<h1 align="center">🎉 Waifu.it Unleashed!</h1>
<br />
<img align="center" width="256" height="256" src="https://avatars.githubusercontent.com/u/79479798?s=200&v=4" />
<br />
</div>

<div align="center">
<h3>A Random API Serving Anime Stuffs</h3>
<h3>🌟 <b>A Random API Serving Anime Wonders</b>
</h3>
<div align="center">
<img src="https://img.shields.io/github/contributors/WaifuAPI/Waifu.it?color=%236CB4EE" />
<img alt="GitHub issues" src="https://img.shields.io/github/issues/WaifuAPI/Waifu.it?color=%236CB4EE">
Expand All @@ -31,44 +28,31 @@ This repository will continue being as open-source while strictly following the

<hr />

# Contributing
# How You Can Contribute

All contributions are greatly appreciated, but I recommend creating an issue or replying in a comment to let me know what you are working on first that way we don't overwrite each other.
Your input is invaluable! Before diving in, let's sync up to avoid overlapping efforts.

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on this project.
## 🌈 Contribution Categories

## Issues
1. **Feature Requests/Enhancements**
2. **Bug Reports**
3. **Questions/Feedback**

- Feature requests/enhancements
- Bug reports
- Questions/feedback
## 🌿 Branching Strategy

## Branches
- **production:** The live, running version. Please refrain from direct changes.
- **staging:** All proposed changes go here. Submit a [pull request](https://help.github.com/en/articles/about-pull-requests) for review.

- production -> don't touch, this is what's running in production
## 🚀 Submitting Your Changes

- staging -> [pull request][pr] this branch for everything
1. **Fork** the repository on GitHub.
2. **Clone** your forked repo locally.
3. Make your changes and **commit** them.
4. **Push** your changes back to your fork.
5. When ready, create a [pull request](https://help.github.com/en/articles/about-pull-requests) for our review.

## Pull Requests

All pull requests are welcome!

- [Fork][fork] the repository on GitHub.

- [Clone][cloning] the forked repo to your local machine.

- Do you changes

- Commit your changes

- Push your changes back up to your fork.

- When you're ready, submit a [pull request][pr] so that we can review your changes.

## Documentation
---

[DOCS.md](DOCS.md)
Explore the [DOCS](DOCS.md) for detailed information.

[fork]: https://help.github.com/en/articles/fork-a-repo
[cloning]: https://help.github.com/en/articles/cloning-a-repository
[pr]: https://help.github.com/en/articles/about-pull-requests
Let's make Waifu.it even more fantastic together! 🌟
76 changes: 76 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Configuration module for managing environment-specific settings.
* @module config
* @type {Object}
*/

import dotenv from 'dotenv';

/**
* Loads environment variables from a .env file into process.env.
* @type {Function}
*/
dotenv.config();

/**
* Application configuration settings.
* @type {Object}
* @property {string} database - Name of the database.
* @property {number} serverPort - Port for the server.
* @property {string} serverHost - Host for the server.
* @property {Object} roles - User roles.
* @property {string} roles.DEVELOPER - Developer role.
* @property {string} roles.ADMIN - Admin role.
* @property {string} roles.MOD - Moderator role.
* @property {string} roles.DB_MOD - Database Moderator role.
* @property {string} roles.PREMIUM - Premium role.
* @property {string} roles.USER - User role.
*/
const config = {
/**
* Name of the database.
* @type {string}
* @default 'mydatabase'
*/
database: process.env.MONGODB_URI || 'mydatabase',

/**
* Port for the server.
* @type {number}
* @default 3000
*/
serverPort: process.env.PORT || 3000,

/**
* Host for the server.
* @type {string}
* @default '127.0.0.1'
*/
serverHost: process.env.HOST || 'http://localhost',

/**
* User roles.
* @type {Object}
* @property {string} DEVELOPER - Developer role.
* @property {string} ADMIN - Admin role.
* @property {string} MOD - Moderator role.
* @property {string} DB_MOD - Database Moderator role.
* @property {string} PREMIUM - Premium role.
* @property {string} USER - User role.
*/
roles: {
DEVELOPER: 'developer',
ADMIN: 'admin',
MOD: 'moderator',
DB_MOD: 'database_moderator',
PREMIUM: 'premium',
USER: 'user',
},
};

/**
* Global configuration object based on the current environment.
* @global
* @type {Object}
*/
global.config = config;
Loading
Loading