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 🙏

© 2026 – Pkg Stats / Ryan Hefner

structr-4-tasks

v0.1.9

Published

A library that exposes REST connections to an instance of Structr

Downloads

11

Readme

structr-4-tasks

-- A library that provides simplified access to a Structr's REST interfaces. it also can help streamline some of your maintenanc needs by streamlining the process of making backups and publishing them to a remote location (currenty implemented with AWS S3. Hopefully you find this library useful for standalone operations as well as for use in conjunction with other libraries (like Gulp)

Example - Getting Started

//a variable to hold the structr utility object
var structr;

//simultaneously require and initialize the connection
require('structr-4-tasks').init("notyourusername", "notyoursmypassword")
   .then(function(newStructrObject){
      structr = newStructrObject;
   })
   .then(yourStuff) //<--the entry point into your work that ensures that a valid connection will be available
   .catch(function(e){
      //Oops!  you ended up here if connection failed or you have an untrapped error in yourStuff();
      JSON.stringify(e, null, '\t')
      
      //some automation/scheduling systems like a proper error to correctly understand that this process failed.
      process.exit(-1);
   });

var yourStuff = function(){
   //lets get to work
   //requests the json-schema definition of an entity in your structr
   structr.rest.getSchema("MyEntity", "default").then(function(response){
      //if you specify an optional logger (like with gulp-utils), it is available throught the structr.log member;
      //this is handy if you're using the library with gulp and would like get the pretty logging      
      structr.log(response.result.result_count) 
      })  
};

Dependencies

structr-4-tasks uses the following NPM packages internally

argv lodash minimist q request request-promise s3 simple-publishers

Interfaces

.init(username, password, logger, options) the logger input

structr-4-tasks.rest

.get(entity, view, urlOptions) simple get function, optionally allow you specify additional argument

.post(entity, data) post data to the

.put(entity, id, data) note: not yet implmeented //todo

.delete performs a delete post against a single ID. will not allow you to delete all nodes at onces

.getSchema(entity, optionalView)

Backup structr-4-tasks.backup[...]

.run(fileName, publishOptions) .move(fromFile, toFile) //note to rename these By omitting an options object, you are implicitly accepting the following defaults;

var defaultOptions = {
    protocol : ['http://', 'https://'].indexOf(argv['protocol']) > -1 ? argv['protocol'] : "http://",
    server : argv['server'] || "127.0.0.1",
    port : argv['port'] || undefined,
    loginResource : "structr/rest/login",
    maintenanceResource : "structr/rest/maintenance/sync",
    restBase : "structr/rest",
    installLocation : argv['structr-install'] || '/usr/lib/structr-ui',
    verbose: false,
    logger: console
};

This means that you can provide command line options to overrise the following properties

  • protocol
  • server
  • port
  • installLocation typically /usr/lib/structr-ui on most linux systems

Optionally you can set the logger to be your preferred logging function. if you don't provide a value, the default console logger will be used. this is helpful if you are using another library which uses a specialised logging function, as is commonly done when using Gulp.

You can provide a reference to any the top level object, in so much as it has a log() function. For example if used in a regular node context, if you omit the logger argument, providing console or console.log (either will work). the following are functionally equivalent

alternatively, if you're using structr-4-tasks with a library like 'gulp-utils' you can provide your utils reference example

var structr = require('structr-4-tasks')
structr.init("myusername", "mypassword", console)

//Or all at once
var structr = require('structr-4-tasks').init("myusername", "mypassword", console)

//if you're using gulp-util
var gulp = require('gulp');
var gulpUtils = require('gulp-util');
var structr = require('structr-4-tasks').init("myusername", "mypassword", gulpUtils)

Best practice Use environment variables in your code to handle the username and password so that you don't have credentials in your code. example:

var structr = require('structr-4-tasks).init(process.env.username process.env.password)

Note:

the REST function in the library are not attached to the structr.rest until the library has successfully authenticated. this forces failure on premature RESTful calls to structr.

Known issues:

  • [ ] structr.rest.put is not yet implemented