Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contensis-sync-api

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contensis-sync-api

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

  • 1.0.7
  • latest
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

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

Keywords

FAQs

Package last updated on 06 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc