@indiefellas/nekoweb-api
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@indiefellas/nekoweb-api

A simple typescript wrapper for Nekoweb's API, This package also serves as a dependency for our build scripts.

Installing

$ npm i @indiefellas/nekoweb-api
$ bun i @indiefellas/nekoweb-api
$ pnpm add @indiefellas/nekoweb-api
$ yarn add @indiefellas/nekoweb-api

Examples

To get a website info, you can use this:

import NekoAPI from '@indiefellas/nekoweb-api';
// const { default: NekowebAPI } = require("@indiefellas/nekoweb-api");
// ^^ CommonJS support

let neko = new NekoAPI({
    apiKey: 'YOUR_API_KEY_HERE',
});

let response = await neko.getSiteInfo('jbcarreon123');
console.log(response)

Uploading a file:

import NekoAPI from '@indiefellas/nekoweb-api';
import fs from 'node:fs'

let neko = new NekoAPI({
    apiKey: 'YOUR_API_KEY_HERE',
});

let file = fs.readFileSync('./README.md')
let response = await neko.upload('/README.md', file);
console.log(response)

Nekoweb API

You can interface with the Nekoweb API using this library.

Initializing

First, we need to initialize the API:

import NekoAPI from '@indiefellas/nekoweb-api';

let neko = new NekoAPI({
    apiKey: 'YOUR_API_KEY_HERE',
    appName: 'Nekoweb API', // (recommended) optional, defaults to NekowebAPI
    request: {} // optional, additional request config to pass for all requests
});

getSiteInfo(username?: string)

  • Accepts a username, but without it, it will request the site info of the owner of the API key specified
  • Returns a SiteInfo class
await neko.getSiteInfo(); // returns info of the API key owner

await neko.getSiteInfo('jbcarreon123'); // returns info for user jbcarreon123

getFileLimits()

  • Returns a Limits class
await neko.getFileLimits();

listDir(path: string = '/')

  • Accepts a directory path, defaults to / if nothing provided
  • Returns a Folder[] array
await neko.listDir(); // returns contents of /

await neko.listDir('/dist'); // returns contents of /dist

create(path: string, isFolder: boolean = false)

  • Accepts a path of the file/folder, and if isFolder (defaults to false).
await neko.create('/nekoweb.html'); // Creates a file named nekoweb.html

await neko.create('/hello', true); // Creates a folder named hello

await neko.create('/hello/hi.txt'); // Creates a file named hi.txt inside of the hello folder

upload(path: string, file: Buffer)

  • Accepts a path for the file's path, and a file buffer for the actual file itself.
  • If the file is 100MB or over, it will use BigFile for uploads automatically.
let file = fs.readFileSync('./hi.txt');
await neko.upload('/hello/hi.txt', file);

rename(oldPath: string, newPath: string)

  • Accepts the oldPath of the file/folder you wanna rename/move, and newPath of the new path you wanna rename/move.
await neko.rename('/hello/hi.txt', '/hello/hai.txt'); // Renames hi.txt to hai.txt

await neko.rename('/hello/hai.txt', '/hai.txt'); // Moves hai.txt to /

edit(path: string, content: string)

  • Accepts a path for the file you wanna edit and content for the content of that file.
await neko.edit('/hai.txt', 'Haaaiiiiiiiii!!!!!')

delete(path: string)

  • Accepts the path you want to delete.
await neko.delete('/hai.txt');

createBigFile()

  • Returns a BigFile object you can use to upload files more than 100MB.
let bigfile = await neko.createBigFile();

BigFile

append(file: Buffer)

  • Accepts a file to append. This will automatically split it to 100MB chunks if needed.
let file = fs.readFileSync('./reallybigfile.zip');
await bigfile.append(file)

appendChunk(chunk: Buffer)

  • Basically append but instead of the wrapper automatically splits it, you do the job of splitting it.
let file = fs.readFileSync('./reallybigfile.zip');
await bigfile.appendChunk(file)

move(filepath: string)

  • Accepts a filepath for the path of the file you just appended.
await bigfile.move('/reallybigfile.zip')

import()

  • Imports the file you just appended. Only works on ZIP files.
await bigfile.import()

Credits

This library uses Nekoweb's API.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @indiefellas/nekoweb-api

Weekly Downloads

27

Version

1.2.0

License

MIT

Unpacked Size

22 kB

Total Files

9

Last publish

Collaborators

  • jbcarreon123
  • thnlqd