npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

operafr

v1.1.4

Published

Official package to speed up uploads to the open source service **OperaFR**

Downloads

171

Readme

operafr

Official package to speed up uploads to the open source service OperaFR

🔗 Links

Official OperaFR repository: https://github.com/Logic-Layer-Dev/OperaFR

How to use

The package's functions are centered around 3 main methods: instantiate, allocate and upload.

The instantiate function is responsible for creating an object capable of performing the upload tasks. It necessarily needs the following items to be spawned:

const operaUploaderLib = require("operafr");

{...}

const operaUploader = await operaUploaderLib.instantiate({
    serverUrl: "localhost",
    token: "<token>",
    requestPort: 5555,
    publishPort: 5556,
})

The requestPort and publishPort can be changed if the service is running on different ports on the target server.

| Key | Explanation | | :---: | :---: | | serverUrl | Server where OperaFR service is running | | token | Authentication token obtained by the login route for the user representing the system. | | requestPort | Port where the Request/Reply service is running | | publishPort | Port where the Pull/Req service is running |

After instantiation, you can now perform the upload steps. To upload a file, you must use the allocate method.

const initialParams = await operaUploader.allocate("<filepath>", { 
    publicUrl: false,
    folderId: <int> //Destiny folder id from server
});

The initialParams will receive this information structure if communication with the server is successful:

{
  status: 201,
  message: 'File created successfully',
  system_filename: '374bcca8-a564-41b9-a61c-8f9fb3793956.<extension>', //Random string 
  public_url: null //Random string if publicUrl = true
}

The public_url can be used for later consumption of the file in the /files/<public_url> route. The system_filename will be used in the upload method to append the chunks to the correct file.

await operaUploader.upload(initialParams.systemFilename, "<filepath>", 
{
    chunckSize: (1024 * 1024) * 4 // 4MB example
}); 

After this call, the file chunks will go to the destination file created on the Opera server. The "await" can be excluded, since it is not necessarily necessary to wait for a response from the server. This way, the client side can be freed from waiting, making everything more dynamic.

The full code:

const operaUploaderLib = require("operafr");

async function main() {
    const operaUploader = await operaUploaderLib.instantiate({
        serverUrl: "localhost",
        token: "<token>",
        requestPort: 5555, //Default Port
        publishPort: 5556, //Default Port
    })

    const initialParams = await operaUploader.allocate("<filepath>", { 
        publicUrl: false,
        folderId: 4 //Example ID
    });

    await operaUploader.upload(initialParams.systemFilename, "<filepath>", {chunckSize: (1024 * 1024) * 4}); // 4MB example
}

main();