
Research
Namastex.ai npm Packages Hit with TeamPCP-Style CanisterWorm Malware
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.
loopback-bakery
Advanced tools
This is a toolkit to easily create test data for loopback based applications. It is heavily inspired by Django's Model Mommy.
npm install --save loopback-bakery
Import the module and create a recipe for a loopback PersistedModel:
var app = require('../server'); //path to your loopback server script
var bakery = require('loopback-bakery');
//...
var userRecipe = bakery.Recipe(app.models.User);
userRecipe({
email: 'user@loopback.test',
password: 'xxx'
}).then((user) => {
console.log(user);
});
Or use await:
let newUser = await userRecipe({email: 'user@loopback.test', password: 'xxx'});
You can pass default values when creating the recipe:
var userRecipe = bakery.Recipe(app.models.User, {password: 'xxx'});
var user = await userRecipe({email: 'user@loopback.test'});
You can create multiple samples with quantity():
var userList = await recipe.quantity(3)({name: 'Steven', email: 'steven@mail.test'});
console.log(userList.length); //3
Instead of fixed attributes you can use functions that are resolved to attribute values before the new record is created:
var userRecipe = bakery.Recipe(app.models.User, {
password: 'xxx',
email: () => {
return 'user@loopback.test';
}
});
userRecipe().then((user) => {
console.log(user);
});
This is handy if you use fakerjs to generate your test samples:
var faker = require('faker/locale/de');
//...
var userRecipe = bakery.Recipe(app.models.User, {
password: 'xxx',
email: faker.internet.email
});
userRecipe().then((user) => {
console.log(user);
});
Support for Promises is also available. Instead of returning an attribute your function can return a Promise:
var userRecipe = bakery.Recipe(app.models.User, {
password: 'xxx',
email: () => {
return new Promise((resolve) => {
process.nextTick(() => {
resolve('user@loopback');
});
});
}
});
userRecipe().then((user) => {
console.log(user);
});
The bakery allows to easily create users and roles. Use the built-in UserRecipe:
var app = require('../server'); //path to your loopback server script
var bakery = require('loopback-bakery');
//...
var adminUserRecipe = bakery.UserRecipe(app.models.User).withRole('admin', app.models.Role);
let adminUser = await adminUserRecipe({email: 'admin@loopback.test', password: 'admin'});
The recipe will create a new role in case the required user role does not exist.
Use cycle() to rotate a list of sample values:
let pets = bakery.cycle(['dog', 'cat', 'rabbit']);
console.log(pets()) //dog
console.log(pets()) //cat
console.log(pets()) //rabbit
console.log(pets()) //dog
//...
var bakery = require('loopback-bakery');
var logger = require('debug')('samples');
bakery.withLogging(logger);
var todoRecipe = bakery.Recipe(app.models.TODO);
// Logs: 'Created TODO with attributes {"title":"Write Email to John","text":"Some more infos about the TODO..."}'
todoRecipe({
title: 'Write Email to John',
text: 'Some more infos about the TODO...'
});
FAQs
Toolkit to create sample data for loopback models
The npm package loopback-bakery receives a total of 1 weekly downloads. As such, loopback-bakery popularity was classified as not popular.
We found that loopback-bakery 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
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.