NpmTarHostingExample
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v10View latest version
This project creates a simple "Hello World" npm package that can be installed via URL.
hello-world-package.js- HTTP endpoint that generates and serves the npm package as a TAR archivepackage.json- Template for the npm package's package.jsonindex.js- Template for the npm package's main fileREADME.md- This README file
The hello-world-package.js file is set up as an HTTP endpoint. When accessed, it will generate a TAR archive of a simple npm package that exports a "Hello World" function.
To install the package directly from the URL:
npm install [url-to-the-http-endpoint]
For example, if your Val Town endpoint is at https://api.val.town/v1/run/username/hello-world-package, you would run:
npm install https://api.val.town/v1/run/username/hello-world-package
After installation, you can use it in your JavaScript code:
const helloWorld = require('hello-world-package');
helloWorld(); // Logs "Hello World" to the console
MIT