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

dir-uploader

v1.1.3

Published

An uploader module to upload all files in a directory or to upload files of a type. It sends a multipart request to the endpoint with all files attached to it

Downloads

144

Readme

dloader(dir-uploader: A single or multi directory uploader using a REST Multipart request)

NPM Quality Gate Status js-standard-style

Description: This is a npm module to upload all files in a directory or to upload files of a specific type to a rest end point using multipart request. If you just pass in a file instead of directory then it will just upload the given file. If there are multiple files in a directory it sends one multipart request attaching all the files to it. Please see the configuration section for the option details

  • Technology stack: This is a npm module written in Vanilla JS.
  • Status: This is the first functional version of this module. We are planning to add a change log starting from the next version

Dependencies

It is dependent on the following node modules

  • "form-data": To create multipart request object
  • "node-fetch": To send REST request
  • "colors": For colorful output messages in terminal

Installation

One way is to keep dir-uploader as a dependency in your package.json pointing to its current repo

npm install dir-uploader --save-dev

To update to the latest version

npm update dir-uploader 

Configuration

The following are the configurable options using command npm run send-data

url: The URL of REST end point where we post the files

result-path: the folder or file that need to be posted

metadata-file: meta data file that need to be posted

export-file-type: file type you want uploaded or true for all files in directory

delete-files: do we want to delete folder files after successfully sending the files

Usage

You can use it using a commandline or inside another JS file as an import.

Single Directory Upload

From Command line you can either

  • create and use send-data npm task
  • or directly call export function sendData

Using send-data npm task:

package.json script line would look like this

"send-data": "node -e 'require(\"dir-uploader\").sendData()'"

At command prompt:

npm run send-data -- url='http://localhost:9456/resultmultipartupload' result-path='_test-reports/e2e-test-results/browser-based-results_2020-01-15T17_04' metadata-file='_test-reports/e2e-test-results/browser-based-results_2020-01-15T17_04/metadata.json' export-file-type=xml delete-files=false

Using js exported function sendData:

node -e 'require("./dir-uploader").sendData("http://localhost:3020/post","tests/e2e/sample-exports/browser-based-results","tests/e2e/sample-exports/test.json",false,true)'

Multiple Directory Upload

Similarly you can also upload multiple directory using a command like

node -e 'require("./dir-uploader").sendMultiFolderData("http://localhost:3020/post","tests/e2e/sample-exports/browser-based-results",'metadata.json', false, 'xml', 'tests')'

You can also see an example of how to use module with single and multiple file upload options in the tests folder "runTests.js" file. These are e2e tests for this module. You can run them using the instructions given in the below section

How to test the software

This module includes a tests folder that contains a simple node test app, unit tests and end to end(e2e) tests. The tests runner is mocha (https://mochajs.org/). To run the tests

  1. Firstly, install all the dependencies by npm install.
  2. Go into testapp dir cd tests/testapp and run npm install to install testApp dependencies.
  3. It is easier to run when you install mocha as a global dependency npm i -g mocha
  4. Start the node test app node tests/testapp/server.js (tested on node v13).
  5. Run the tests mocha tests/runTests.js

Logging

This module includes logging using the winston node js plugin. If you need to lower the logging level from error for any reason you can change the logging level inside the dir-uploader.js file.

Known issues

We are actively using this module as a component in our Continuous Integration Cycle and we don't have any open issue. Please contact us if you run into any issues.

Contact / Getting help

You can contact any of us if you run into any issues

License

MIT License

Credits and references

We needed this module to export our test results to a rest end point so we wrote it. We have tried to make it general with the configurable options as possible. Please let us know if you have any suggestions. We thank you to "Philips Health Solutions" in general to give us opportunity to write this plugin.