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

aws-s3-facia-tool

v2.0.1

Published

API on top of facia tool storage

Downloads

9

Readme

aws-s3-facia-tool

API on top of facia tool storage

Dependencies

This package has a peer dependency on aws-sdk version 2.x.

Installation

npm install aws-s3-facia-tool --save

Usage

const facia = require('aws-s3-facia-tool');
const client = new facia.Client({
    'bucket': 'bucket-used-by-fronts-tool',
    'env': 'CODE',
    'configKey': 'where/config.json/lives',
    'configHistoryPrefix': 'path/containing/config/history',
    'collectionHistoryPrefix': 'path/containing/collections/history',
    'collectionsPrefix': 'path/containing/collection.json',
    'pressedPrefix': 'path/containing/pressed.json',
    'maxParallelRequests': 6,
    'maxDaysHistory': 7
});

Config

const facia = require('aws-s3-facia-tool');
const client = new facia.Client({});
facia.Config(client).fetch()
.then(config => {
    // use the config here
})
  • Config.fetch() - Fetch the config JSON from the bucket, returns a Config class
  • Config.head() - Performs a head action, the resulting promise is resolved with the config metadata (e.g. ETag, LastModified)
  • Config.get() - Returns the Config class using in memory cache, it reads from the bucket only when the cache is empty.
  • Config.json() - Returns the config JSON instead of the utility class. It uses the cache
  • Config.fetchAt(key) - Returns a Config class reading from key instead of the internal configuration

Config class

Instances of Config class have the following methods

  • hasFront(front) - Boolean, whether a front exists
  • hasCollection(id) - Boolean, whether a collection with id exists
  • listFrontsIds(priority) - List of all front id. Optionally filter by priority
  • listCollectionsIds() - List of all collection id
  • front(path) - Return a Front class for the given path
  • collection - Return a Collection class for the given id
  • fronts.find(query) - Return a list of Front classes for all paths that match the query
  • collections.find(query) - Return a list of Collection classes for all paths that match the query

Collection

const facia = require('aws-s3-facia-tool');
const client = new facia.Client({});
facia.Collection(client).fetch()
.then(collection => {
    // use the collection here
})
  • fetch (id, config) - Fetch a collection id. config is optional if you're just interested in the collection content, otherwise pass a config object
  • fetchAt (id, key, config) - Fetch a collection with id at a specified key
  • list() - List all collections in the bucket (including the ones that have been removed from fronts)

Collection class

Instances of Front class have the following methods

  • forEachArticle(action) - Perform an action for each item in the collection. action receives (stage, article) where stage is live / draft / treats
  • setContent(json) - Set the content of the collection
  • setKey(key) - Set the key storing the collection content
  • toJSON() - Return the collection as JSON. The result object contains
    • config: the collection config
    • collection: the collection content
  • trails(stage) - Return the list of trail in stage (live / draft / treats)
  • lastUpdated() - Return the last updated date
  • isBackfilled() - Whether the collection has a backfill
  • hasMetadata(type) - Whether the collection has metadata of type (e.g. collection tags)
  • layout() - Return the collection layout
  • visibleStories(scope) - Number of visible stories (above show more) on desktop and mobile

Front

const facia = require('aws-s3-facia-tool');
const client = new facia.Client({});
facia.Front(client).fetch()
.then(front => {
    // use the front here
})
  • fetch (path, config) - Fetch a front with path. config is optional, the tool will get it from S3 if not specified

Front class

Instances of Front class have the following methods

  • toJSON() - Return the front a JSON. The result object contains
    • config: the front configuration
    • collections: the collections configuration
    • collectionsFull: the collections content
  • setCollection(id, collection) - Set the content a collection
  • collection(id) - Return a Collection class for the collection with id
  • lastUpdated() - Return the last updated date
  • priority() - Return the explicit priority
  • listCollectionsIds() - List all collection id

Press

const facia = require('aws-s3-facia-tool');
const client = new facia.Client({});
facia.Press(client).getLastModified('front-path', 'live')
.then(lastModified => {
    // date
})
  • getLastModified(path, location) - Get the last modified date of a front in either live or draft