PlugAPI is a modular, plug-and-play API system built using TypeScript, Express, and EJS. It allows developers to easily add or modify plugins without altering the core structure. Each plugin is loaded dynamically, and the API documentation updates automatically on the website without the need for manual HTML edits.
- ⚙️ Plug-and-Play Architecture: Easily add new features or APIs by creating plugins. The system automatically loads all available plugins from the plugins directory.
- 🧩 Modular Design: Every plugin is a self-contained module that handles specific API routes, keeping the core code clean and organized.
- 📐 TypeScript Powered: Written in TypeScript for better type safety, development experience, and maintainability.
- 🌐 Express.js Integration: Utilizes Express.js for routing and middleware, making it flexible and easy to extend.
- 🎨 EJS Templating: The API uses EJS for dynamic rendering of web pages, including automatically updating API documentation.
- 📝 Language: TypeScript
- 🔌 Backend Framework: Express.js
- 📄 View Engine: EJS
- 🛠 Build Tool: TypeScript Compiler (tsc)
-
Clone the repository:
git clone https://github.com/YourUsername/PlugAPI.git cd PlugAPI
-
Install dependencies:
npm install
-
Build the project:
npm run build
-
Start the API:
npm start
-
Access the API: Visit http://localhost:3000 to view the running API and documentation.
Name | Method | Route | Parameters | Description |
---|---|---|---|---|
getAudioInfoAndLink |
GET | /api/getAudioInfoAndLink |
link (YouTube URL) |
API for getting audio information and links |
getTranslate |
GET | /api/getTranslate |
langTo (language code), text (text to translate) |
API for text translation |
getVideoInfoAndLinks |
GET | /api/getVideoInfoAndLinks |
link (YouTube URL) |
API for getting video information and links |
imageSearch |
GET | /api/imageSearch |
query (search term) |
API for searching images |
instaDownloader |
GET | /api/instaDownloader |
link (Instagram URL) |
API for getting video information and links from Instagram |
pinterest |
GET | /api/pinterest |
query (search term) |
API for searching images on Pinterest |
PlugAPI is designed around plugins that handle specific functionalities of the API. Adding or modifying a plugin is easy, and the system automatically detects new plugins and updates the API documentation displayed on the website.
import { Router } from 'express';
import { Plugin } from '../types/index';
const myPluginLogic = async () => {
return { message: 'Hello from MyPlugin!' };
};
export default (): Plugin => {
return {
name: 'MY_PLUGIN',
description: 'An example plugin to demonstrate how to add a plugin',
parameter: 'query=(optional parameter)',
route: '/api/myplugin',
run: (router: Router) => {
router.get('/myplugin', async (req, res) => {
const response = await myPluginLogic();
res.status(200).json(response);
});
},
};
};
- Inside the
src/plugins
directory, create a new TypeScript file for your plugin, e.g.,myPlugin.ts
. - Implement the plugin using the template above, defining the route, parameters, and API logic.
- Restart the server:
npm start
After restarting, visit http://localhost:3000/docs to see the updated list of APIs.
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature-branch
- Create a pull request.
PlugAPI is licensed under the MIT License.