
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
@pathcheck/data-layer
Advanced tools
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.
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
Install by enter one of the commands below.
npm install @pathcheck/data-layer
-or-
yarn add @pathcheck/data-layer
Once installed, include it
const db = require('@pathcheck/data-layer');
// 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))
To access any of the knex commands, you can simply
const db = require('@sublet/data-layer');
// 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))
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' })
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 @pathcheck/data-layer
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
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
FAQs
Sample data layer for the SafePlaces backend API
The npm package @pathcheck/data-layer receives a total of 40 weekly downloads. As such, @pathcheck/data-layer popularity was classified as not popular.
We found that @pathcheck/data-layer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.