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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@awesomeness-js/graph-s3

v1.1.0

Published

Awesomeness - Graph DB using S3

Readme

Setup

Create an S3 bucket. set the AWESOMENESS_GRAPH_AWS_BUCKET env to the bucket name

For local testing you can do this: Change secrets_example to secrets and fill in the values

AWESOMENESS_DEFAULT_AWS_REGION=us-east-1 AWESOMENESS_GRAPH_AWS_BUCKET=graph.awesomeness.js.com

In production you can delete the secrets folder as long as the envs are set.

Example Usage

import graph from '@awesomeness-js/graph-s3';

Vertex

graph.vertex.add()

graph.vertex.addMultiple() is the same it just takes an array of items


// create a vertex
const vertex = await graph.vertex.add({
	type: 'person',
	name: 'John Doe',
	age: 30,
});

console.log(vertex.id); // will be assigned a uuid4

// create another vertex
const vertex2 = await graph.vertex.add({
	id: '00000000-0000-4000-8000-000000000000',
	type: 'person',
	name: 'Jane Doe',
	age: 25,
});

console.log(vertex2.id); // will be '00000000-0000-4000-8000-000000000000'

graph.vertex.get()

graph.vertex.getMultiple() is the same it just takes an array of items


// get a vertex

const vertex = await graph.vertex.get('00000000-0000-4000-8000-000000000000');

console.log(vertex);

graph.vertex.delete()

graph.vertex.deleteMultiple() is the same it just takes an array of items


// delete a vertex

await graph.vertex.delete('00000000-0000-4000-8000-000000000000');

Edge

graph.edge.add()

graph.edge.addMultiple() is the same it just takes an array of items


// create an edge

await graph.edge.add({
	v1: '00000000-0000-4000-8000-000000000000',
	v2: '00000000-0000-4000-8000-000000000001',
	type: 'friend',
});

graph.edge.search()


// find friends of a vertex

const edges = await graph.edge.search('00000000-0000-4000-8000-000000000000', 'friend');
console.log(edges);

// find friends and enemies of multiple vertices

const edges = await graph.edge.search([
	'00000000-0000-4000-8000-000000000000'
	'00000000-0000-4000-8000-000000000001'
], [
	'friend',
	'enemy',
]);

console.log(edges);

graph.edge.getMultiple()


// find friends of vertex 1
// and enemies of vertex 2
await graph.edge.delete([
	[
		'00000000-0000-4000-8000-000000000001', 
		'friend'
	],
	[
		'00000000-0000-4000-8000-000000000002',
		'enemy'
	],
]);

graph.edge.delete()

graph.edge.deleteMultiple() is the same it just takes an array of items


// delete the friendship between vertex 1 and vertex 2
// 2 still is friends with 1

await graph.edge.delete([
	'00000000-0000-4000-8000-000000000001', 
	'friend',
	'00000000-0000-4000-8000-000000000002'
]);

// delete the friendship between vertex 1 and vertex 2
// 2 is no longer friends with 1

await graph.edge.deleteMultiple([
	[
		'00000000-0000-4000-8000-000000000001',
		'friend',
		'00000000-0000-4000-8000-000000000002'
	],
	[
		'00000000-0000-4000-8000-000000000002',
		'friend',
		'00000000-0000-4000-8000-000000000001'
	],
]);

KV

graph.kv.add()

graph.kv.addMultiple() is the same it just takes an array of items


// create a key value pair
await graph.kv.add('keyBaz', { foo: 'bar' });

graph.kv.get()

graph.kv.getMultiple() is the same it just takes an array of items


// get a key value pair
const kv = await graph.kv.get('keyBaz');
console.log(kv);

// get multiple key value pairs
const kvs = await graph.kv.getMultiple([
	'keyBaz',
	'somethingElse'
]);

graph.kv.delete()

graph.kv.deleteMultiple() is the same it just takes an array of items


// delete a key value pair
await graph.kv.delete('keyBaz');

// delete multiple key value pairs
await graph.kv.deleteMultiple([
	'keyBaz',
	'somethingElse'
]);

Graph Database - Structure


Vertex

S3 Storage Location: your-bucket/vertices/ your-bucket/vertices/00000000-0000-4000-8000-000000000000

Vertex Body

They should be a JSON object. The only reserved properties are id and type, all others are fair game.

id is a uuid4 type is any string

{
	"id": "00000000-0000-4000-8000-000000000000",
	"type": "person",
	"anythingYouWant": "...", 
}

Vertex Metadata

{
	"id": "00000000-0000-4000-8000-000000000000",
	"type": "person",
}

Edge

S3 Storage Location: your-bucket/edges/

un-sharded your-bucket/edges/00000000-0000-4000-8000-000000000000/friend

sharded your-bucket/edges/00000000-0000-4000-8000-000000000000/friend your-bucket/edges/00000000-0000-4000-8000-000000000000/friend/shard.1 your-bucket/edges/00000000-0000-4000-8000-000000000000/friend/shard.2

An edge collection by default is un-sharded. The max size of a edge collection is 100_000 uuids, which is about 4.7mb.

When the number of uuids in the collection exceeds 100_000, the collection will be sharded into multiple files.

OTHER SIZES:

7777 = 365 kb (works for dynamodb)
10k = 469 kb (too big for dynamodb)
25_000 = 1.2 mb
50_000 = 2.4 mb
100_000 = 4.7 mb
250_000 = 11.7 mb
500_000 = 23.4 mb
1_000_000 = 46.8 mb

Edge Body

your-bucket/edges/00000000-0000-4000-8000-000000000000/friend

un-sharded

Just a simple array of uuids.

[
	"00000000-0000-4000-8000-000000000001",
	"00000000-0000-4000-8000-000000000002",
	"00000000-0000-4000-8000-000000000003",
	"00000000-0000-4000-8000-000000000004",
]

sharded

A dictionary with the metadata of all shards.

{
  "shard.1": {
	"v1": "00000000-0000-4000-8000-000000000000", // the uuid of the vertex
	"type": "friend", // the edge type
	"size": 4, // how many uuids are in the shard,

	"id": "shard.1", // the id of the shard
	"lastId": "00000000-0000-4000-8000-000000000004", // used for routing to the correct shard
  },
  "shard.2": {
	"v1": "00000000-0000-4000-8000-000000000000", // the uuid of the vertex
	"type": "friend", // the edge type
	"size": 4, // how many uuids are in the shard,

	"id": "shard.2", // the id of the shard
	"lastId": "00000000-0000-4000-8000-000000000008", // used for routing to the correct shard
  }
}

Edge Metadata

your-bucket/edges/00000000-0000-4000-8000-000000000000/friend

un-sharded

{
	"v1": "00000000-0000-4000-8000-000000000005",
	"type": "someEdgeType",
	"size": 4,
}

sharded

{
	"v1": "00000000-0000-4000-8000-000000000005",
	"type": "someEdgeType",
	"size": 8,
	
	// 2 additional properties
	"id": "edges/00000000-0000-4000-8000-000000000000/friend",
	"supernode": true,
}

Shard Body

Same as an un-sharded edge collection body.

your-bucket/edges/00000000-0000-4000-8000-000000000000/friend/shard.1

[
	"00000000-0000-4000-8000-000000000001",
	"00000000-0000-4000-8000-000000000002",
	"00000000-0000-4000-8000-000000000003",
	"00000000-0000-4000-8000-000000000004",
]

your-bucket/edges/00000000-0000-4000-8000-000000000000/friend/shard.2

[
	"00000000-0000-4000-8000-000000000005",
	"00000000-0000-4000-8000-000000000006",
	"00000000-0000-4000-8000-000000000007",
	"00000000-0000-4000-8000-000000000008",
]

shard metadata

Shard metadata is the same as edge metadata, but with the addition of the id and lastId properties.

id is the id of the shard.

lastId is the last uuid in the shard. This is used for quickly routing to the correct shard.

your-bucket/edges/00000000-0000-4000-8000-000000000000/friend/shard.1

{
	"v1": "00000000-0000-4000-8000-000000000000",
	"type": "friend",
	"size": 4,

	// special shard properties
	"id": "shard.1",
	"lastId": "00000000-0000-4000-8000-000000000004",
}

your-bucket/edges/00000000-0000-4000-8000-000000000000/friend/shard.2

{
	"v1": "00000000-0000-4000-8000-000000000000",
	"type": "friend",
	"size": 4,

	// special shard properties
	"id": "shard.2",
	"lastId": "00000000-0000-4000-8000-000000000008",
}

KV Bucket

your-bucket/kv/anyStringLessThan420Chars

Body

No size limit.

Can be: string | number | boolean | object

{
	"key": "value",
	"key2": "value2",
	"deep": {
		"key": "value",
		"key2": "value2",
	}
}

Metadata

{
	"k": "anyStringLessThan420Chars",
	"type": "string | number | boolean | object",
}