Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@entity-factory/core
Advanced tools
Entity Factory is a library used for quickly creating fixture data from plain objects or classes using faker. Inspired by laravel's factories for generating test data. Currently the library supports plain JS objects and Typeorm entities.
npm install --save @entity-factory/core
Try it on Runkit
const { EntityFactory, ObjectBlueprint } = require('@entity-factory/core');
class UserBlueprint extends ObjectBlueprint {
constructor() {
super();
this.type('user');
this.define(async ({ faker, factory }) => ({
username: faker.internet.userName(),
email: faker.internet.email(),
active: faker.random.boolean(),
}));
// define a state transform to return a user with embedded posts
this.state('with-posts', async ({ faker, factory }) => ({
posts: await factory.for('post').create(2),
}));
}
}
class PostBlueprint extends ObjectBlueprint {
constructor() {
super();
this.type('post');
this.define(async ({ faker, factory }) => ({
title: faker.company.bsBuzz(),
body: faker.lorem.sentences(2),
}));
}
}
export const entityFactory = new EntityFactory({
blueprints: [UserBlueprint, PostBlueprint],
});
// Generate entities
entityFactory
.for('user') // get builder instance for 'user'
.state('with-posts') // get users with posts
.create(3) // generate 3 users with incrementing id's
.then(users => console.log(users));
It is also possible to generate random data using the gen
method available on
EntityFactory
await entityFactory.gen(3, async ({ faker, factory }) => {
return {
name: faker.company.bsBuzz(),
active: faker.random.boolean(),
};
});
FAQs
Create entities on the fly for mocking and testing
We found that @entity-factory/core 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.