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

nexus-server

v0.0.1-alpha2

Published

Simple remote file storage server over HTTP

Downloads

2

Readme

Nexus

Standard - JavaScript Style Guide

Nexus is a simple remote file storage server over HTTP. Easily create, read and update files remotely, using only HTTP. With an easy to use HTTP API and node.js client, it's fast to set up and use.

Nexus is currently an alpha version. Use at your own risk.

Important: The version you see here MAY NOT be the one currently published on npm! To check the latest published version, look at the package on npm.

Documentation is sparse at the moment, I will write some more later. In the mean time take a look at the source code if you're interested.

Features

  • Simple to use HTTP API
    • To download a file, simply make a request: GET /my/resource.json
    • To upload a file, make another simple request: PUT /my/resource.json (POST works too)
  • The given path is the resource path
    • Extensions are optional, but a resource will always be a file
    • E.g. /resource, /resource.json, /dir/subdir/another/resource
  • Support for read (r), write (w) and append (a) modes (may depend on the store used)
  • Abstracts file handling, making it possible to use multiple types of stores

Roadmap

Soon

  • Support partial content and Range headers

Longer

  • Support for authentication
  • Maybe look into making core functionality transport-independent
    • WebSocket support would make a nice addition
    • Vanilla TCP might be fun too

Install

npm install nexus-server

Stores

In order to get Nexus running, you need a store. As the name suggests, a store is where your files will be... stored. Nexus abstracts file handling, providing a lot of flexibility in what storage back-ends to use.

By default Nexus comes bundled with FileStore, a store which uses the local file system to store resources. Because the store is so important, you'll have to set one manually.

It's simple to make your own store, as they use streams. Any object which has the methods createReadStream(resource, mode) and createWriteStream(resource, mode) and which return a Promise that resolves in the appropriate stream will work fine. For an example, see FileStore.js.

Setting up a server

A few lines of code say more than a thousand words.

const path = require('path')
const Nexus = require('nexus-server')

const server = new Nexus.Server({
  // FileStore requires an absolute path!
  store: new Nexus.FileStore(path.resolve(process.cwd(), './resources'))
})

server.listen().then(() => {
  // Get the address from the underlying http.Server
  const address = server.server.address()
  console.log(`server listening on ${address.address}:${address.port}`)
}).catch(err => {
  console.error(`error starting server: ${err.message}`)
})

Enabling SSL

By setting options.secure to true and providing the appropriate keys and/or certificates in the options object, HTTPS will be enabled and your connection will be secure.

Note that Nexus uses http.Server, so all options that can be provided to https.createServer([options]) will be valid for use.

const server = new Nexus.Server({
  secure: true,
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
})

Standard - JavaScript Style Guide

License

Copyright 2017 Michiel van der Velde.

This software is licensed under the MIT License.