Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
lauf is a lightweight migration runner for Typescript.
🐘 Uses PostgreSQL for keeping track of migrations.
🔗 Guaranteed consistency for your PostgreSQL data via transactions.
☁️ Handle arbitrary further databases or file storages in your migrations (e.g., S3 or GCS).
👩💻 Migration order is defined in code, not implicitly through files in a directory.
📦 Use any packages you want in your migrations.
🪶 Lightweight: only a single dependency (pg
).
Migrations can be run like
import { runMigrations } from 'lauf'
import pg from 'pg'
await runMigrations({
setup: async () => {
const pgClient = new pg.Client({ connectionString: process.env.POSTGRESQL_URL })
await pgClient.connect()
return { pgClient }
},
teardown: ({ pgClient }) => pgClient.end(),
migrations: [
{
id: '2022-07-09-create-users',
description: 'Create users',
up: ({ pgClient }) => pgClient.query(
`CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);`
),
down: ({ pgClient }) => pgClient.query(`DROP TABLE users;`),
},
// add further migrations
],
logger: (msg) => console.log(msg)
})
For organizing migrations, each migration can also be kept in a separate file like
import { Migration } from 'lauf'
const migration: Migration = {
id: '2022-07-09-create-users',
description: 'Create users',
up: ({ pgClient }) => pgClient.query(
`CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);`
),
down: ({ pgClient }) => pgClient.query(`DROP TABLE users;`),
}
export default migration
Then the files can be run as follows:
await runMigrations({
// see above
migrations: [
import('./2022-07-10-create-users-table.js'),
// add further migrations here
].map(v => v.default),
})
Setting the mode
option to up
or down
you can migrate step-wise up or down. The default value is latest
which runs all migrations.
The setup
function can return arbitrary further properties. All returned properties will be passed to the migrations and the teardown
function. For example:
await runMigrations({
setup: async () => {
const pgClient = new pg.Client({ connectionString: process.env.POSTGRESQL_URL })
await pgClient.connect()
const gcs = new Storage(process.env.GCS_CREDENTIALS)
return { pgClient, gcs }
},
teardown: ({ pgClient, gcs }) => pgClient.end(),
migrations: [
{
id: '2022-07-09-create-users',
description: 'Create users',
up: async ({ pgClient, gcs }) => {
await pgClient.query(
`CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);`
)
await gcs.upload(...)
},
down: ({ pgClient, gcs }) => pgClient.query(`DROP TABLE users;`),
},
// add further migrations
],
})
docker run -d --name pg-lauf -e POSTGRES_PASSWORD=test -p 5432:5432 postgres:14
export POSTGRESQL_URL=postgres://postgres:test@127.0.0.1:5432/postgres?sslmode=disable
npm run build && npm test
FAQs
Migration runner for Typescript
We found that lauf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.