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

contensis-sync-api

v1.0.7

Published

Allows you to Query Contensis with relevant credentials in order to sync files

Downloads

25

Readme

Usage

You will need Contensis 9 to use this plugin, to get started, install contensis-sync-api as a development dependency:

npm install --save-dev contensis-sync-api

Now create an instance of the API

var contensisSyncAPI = require('contensis-sync-api');

var ContensisSyncApiInstance =  contensisSyncAPI.create({
	"user": "user",
	"password": "pass",
	"cmsUrl": "http://contensis-cms-url",
	"project": "Project Name"
    });

API

contensisSyncApi.create(Config)

Creates an instance of the Sync API to interact with

The Config object is used to create a REST connection to Contensis, you should ideally add your contensis credentials to a json file:

{
	"user": "user",
	"password": "pass",
	"cmsUrl": "http://full-cms-url",
	"project": "Project Name"
}

You can then read it in with:

var fs = require('fs')
//Remember to add your contensis-credentials.json to your .gitignore, so no one else can use your details!
var credentials = JSON.parse(fs.readFileSync('../contensis-credentials.json', 'utf8'))
//Now you can create the object using the credentials
var ContensisSyncApiInstance = contensisSyncAPI.create(credentials);

contensisSyncApi.getObject([options], callback)

Get an object from contensis along with its ETag.

  • options:
    • path: path of the object you wish to retrieve info for

ContensisSyncApiInstance.getObject({ path: 'foo/bar.txt' }, function(err, rsp){
    // The return object is very lightweight, because we are just interested in syncing files we really only care 
    // about the MD5 hash of the file.
    var ETag = rsp.ETag;
    var success = rsp.Success
    //Do something
});

contensisSyncApi.listObjects([options], callback)

List all files on a particular path that exist.

  • options:
    • prefix: path of the files inside the specified project you wish to retrieve such as foo. You can add a slash to the end or start, if not added it will handle this for you.
function listObjects(cb){
    listItems = ContensisSyncApiInstance.listObjects({ Prefix: 'foo' }, function(err, paths){
        if(err){ return cb(err); }

        for (let path of paths) {
            console.log(path)
        }
        return cb();
    });
}

contensisSyncApi.deleteObjects([options], callback)

List all files on a particular path that exist.

  • options:
    • prefix: path of the files inside the specified project you wish to retrieve such as foo. You can add a slash to the end or start, if not added it will handle this for you.

function deleteObjects(cb){
    deleteItems = ContensisSyncApiInstance.deleteObjects(['foo/1.txt', 'foo/2.txt'], function(err, rsp){
        if(err){ return cb(err); }
        
        return cb(null, rsp.Success)
        });
    });
}

contensisSyncApi.putObject(file, callback)

This method allows you to upload a file to Contensis, It will overwrite existing files. Most file types are supported other than complex non file like content such as Forms, Templates and Databases.

  • File
    • path This is the destination path of the file
    • body This is a Vinyl contents object see: https://www.npmjs.com/package/vinyl

License

MIT License