Skip to content

neoxr/open-api

Repository files navigation

OPEN-API

JavaScript (ESM) base website script using a plugin as a router that is lightweight and easy to customize.

Open-API

Features

  • Plugin as Router
  • Auto List Feature
  • High Optimation
  • Easy to Customize
  • Show User IP
  • Restrict Access (IP Whitelist)
  • Request Per Minute Limit
  • Suitable for Rest API
  • etc.

Router

This is an example of a router

import { Loader } from '../lib/index.js'
const Scraper = Loader.scrapers

export const routes = {
   category: 'main',
   path: '/api/tempo',
   parameter: ['q'],
   method: 'get',
   execution: async (req, res, next) => {
      const { q } = req.query
      const json = await Scraper.tempo.search(q)
      res.json(json)
   },
   error: false,
   authorize: false,
   rpm: false,
   protect: true,
   premium: false,
   restrict: false
}

Middleware

There are two types of middleware: global middleware, which is applied based on route attributes, and 'only' middleware, which is applied directly in the router or plugin.

1. Global Middleware

export const routes = {
   error: Boolean,
   authorize: Boolean,
   rpm: Boolean,
   protect: Boolean,
   premium: Boolean,
   restrict: Boolean
}

2. Only/Single Middleware

import some from './middlewares/only/some.js'

export const routes = {
   middleware: [some]
}

Installation & Run

$ yarn
$ node .

or want to use pm2

$ yarn
$ npm i -g pm2
$ pm2 start pm2.cjs && pm2 logs

Example

/api/tempo?q={query}

Conclusion

Open-API is part of Neoxr API

About

Base Script for API Website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •