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

@sublet/hulk-dl-postgres

v0.0.3

Published

Postgres Data layer for the Hulk Express server

Downloads

3

Readme

Safeplaces Data Layer Library

The Safeplaces Data layer is a sample library. It contains migrations, seeds, and the general schema for working with both the public and private libs.

Under the hood this utilizes the Knex library. So all services can access the standard Knex commands. More below.

The Safeplaces Backend deploys two different types of databases. One is public facing and the other is private. The reasons for this is a security concern that was identified early on. We don't want the published (redacted) data being stored in the same place as the ingested data. Additionally, we don’t want to be writing data from the public endpoints to the private database.

Environment Variables

The config is currently pre-setup for you so all you need to do is provide the correct environment variables.

DB_HOST=localhost
DB_PASS=password
DB_USER=safepaths
DB_NAME=safepaths

DB_HOST_PUB=localhost
DB_PASS_PUB=password
DB_USER_PUB=safepaths
DB_NAME_PUB=safepaths_public

SEED_MAPS_API_KEY=maps_api_key

Installation and Usage

Install by enter one of the commands below.

npm install @sublet/hulk-dl-postgres

-or-

yarn add @sublet/hulk-dl-postgres

Once installed, include it

const db = require('@sublet/hulk-dl-postgres');

// Pull the Organization Service from the Private database
const { organizationService } = db.private

organizationService.all().then(data => console.log('All Data: ', data))

// Pull the Access Codes Service from the Public database
const { pointService } = db.public

pointService.all().then(data => console.log('All Data: ', data))

Knex

To access any of the knex commands, you can simply

const db = require('@sublet/hulk-dl-postgres');

// Pull the Organization Service from the Private database
const { organizationService } = db.private

organizationService.table.insert({ name: 'Hello Name' }).returning('*')
  .then(data => console.log('Data: ', data))

organizationService.table.where({ id: 1 }).first()
  .then(data => console.log('Data: ', data))

Knex Helper Commands

Additionally, we have added some helper commands.

const db = require('@sublet/data-layer');

// Pull the Organization Service from the Private database
const { organizationService } = db.private

// Returns all rows
organizationService.all()

// Returns all rows
organizationService.updateOne(1, { name: 'Some other Name' })

CLI

Due to the nature of database management we have built in a small CLI that will allow you to run seeds and migrations. To install enter the following.

This needs to be installed globaly so run the following command.

npm i -g @sublet/hulk-dl-postgres

Migrations

Update the PRIVATE database with the most recent migrations in the development environment.

spdl migrate:latest --scope private --env development

Update the PUBLIC database with the most recent migrations in the development environment.

spdl migrate:latest --scope public --env test

Rollback the public database

spdl migrate:rollback --scope public

Seeds

Seed the PRIVATE database with the correct seed files in the development environment.

spdl seed:run --scope private --env development

Seed the PUBLIC database with the correct seed files in the test environment.

spdl seed:run --scope public --env test