Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/retraigo/kuko
A random api generator using express.js
https://github.com/retraigo/kuko
Last synced: 8 days ago
JSON representation
A random api generator using express.js
- Host: GitHub
- URL: https://github.com/retraigo/kuko
- Owner: retraigo
- License: mit
- Created: 2022-01-29T05:06:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-04T13:17:53.000Z (over 2 years ago)
- Last Synced: 2024-04-26T03:45:10.408Z (7 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kuko
A random file api generator using express.js**Q. Why did you name it Kuko?**
A. I have absolutely no idea.**## Installing
```sh
$ npm install --save-dev kuko # NPM
$ pnpm install kuko # PNPM
```## Usage
```js
import Kuko from 'kuko'
const app = new Kuko()
```### setPort(port)
```js
app.setPort(4000) // returns app
```### setStatic(dir)
Set a directory as a static directory. Express will serve static files from this directory.
```js
app.setStatic("some-cool-dir") // sets "./some-cool-dir" as the static folder and returns app
```### addRoute(route, dir)
Add a route.
`route` - Yes, route.
`dir` - The directory to fetch files from. Must be inside your static directory.
```js
app.addRoute("funny", "funny-images") // returns app
```
Accessing `/funny` would return a random file from `funny-images`### start()
Starts the app using the configuration made with the other methods.### app
You can directly access the express app instance through `new Kuko().app````js
app.app.get("/", (req, res) => res.send("omae wa mou shinderu"))
```## Credits
[retraigo](https://github.com/retraigo)