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

@financial-times/tc-api-s3-document-store

v0.6.9

Published

Module for connecting a Treecreeper&tm; api to an s3 bucket to use as an additional data store for storing properties that are too large to allow efficient querying in neo4j.

Downloads

217

Readme

@financial-times/tc-api-s3-document-store

Module for connecting a Treecreeper api to an s3 bucket to use as an additional data store for storing properties that are too large to allow efficient querying in neo4j.

Any module implementing the same interface can also be passed to other treecreeper packages in order to use alternative choices of store.

When an s3 document store is present, properties which have the type Document will be stored in s3, and will be retrieved from there by graphql resolvers

Creating an instance

This package exports two methods:

  • createStore(s3BucketName) - this will create an instance of the package, creating an s3 client which will authorise with whatever credentials are detected in the environment. Rather than passing in the s3BucketName parameter, the TREECREEPER_DOCSTORE_S3_BUCKET environment variable can be set instead
  • docstore(s3Instance, bucketName) - as above, but allows passing in a custom instance of the AWS.S3 client

API

Every instance implements the following methods:

get(nodeType, code)

Retrieves a record from s3

post(nodeType, code, body)

Writes a record to s3 (if it doesn not already exist)

patch(nodeType, code, body)

Writes a record to s3, updating it if it already exists

delete(nodeType, code)

Deletes a record from s3

absorb(nodeType, code, absorbedCode)

Merges a record (absorbedCode) into another (code) in s3

Output

Each method returns an object containing a body property, which itself contains an object that contains all the properties stored in the docstore for that record

In addition, all write methods return another property, undo, which is a function that can be called to revert the last action.

Example

const { createDocstore } = require('@financial-times/tc-api-s3-document-store');
const { getApp } = require('@financial-times/tc-api-express');
const documentStore = createDocstore('big-musical-properties');

const app = getApp({ documentStore });

app.listen(80);

If lyrics is defined in the schema as a Document, the following request will save them to s3

curl http://localhost:80/Song/stereo -X POST -d '{
        "name": "Stereo",
        "artist": ["pavement"],
        "writer": "stephen-malkmus",
        "lyrics": "Pigs, they tend to wiggle when they walk
The infrastructure rots
And the owners hate the jocks
With their agents and their dates

If the signatures are checked
You\'ll just have to wait

And we\'re counting up the instants that we save
Tired nation so depraved
From the cheap seats see us
Wave to the camera
It took a giant ramrod
To raze the demon settlement

But high-ho silver, ride
High-ho silver, ride

Take another ride to see me home
Listen to me
I\'m on the stereo stereo
Oh my baby baby baby baby babe
Gave me malaria hysteria

What about the voice of Geddy Lee
How did it get so high?
I wonder if he speaks like an ordinary guy?
(I know him and he does)

And you're my fact-checkin' cuz
(Aww)

Well focus on the quasar in the mist
The Kaiser has a cyst
And I\'m a blank want list
The qualms you have and if they stick
They will drown you in a crick
In the neck of a woods
That was populated by
Tired nation on the fly
Everybody knows advice
That was given out for free
Lots of details to discern
Lots of details

But high-ho silver ride
High-ho silver ride

Takes another ride to make me
Oh, get off the air
I'm on the stereo stereo
Oh my baby baby baby baby baby babe
Gave me malaria hysteria"
}