Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
@furystack/repository
Advanced tools
Repository implementation for FuryStack
You can set up a repository in the following way
class MyModel {
public id!: number
public value!: string
}
const myInjector = new Injector()
myInjector
.setupStores(stores => stores.addStore(new InMemoryStore({ model: MyModel, primaryKey: 'id' })))
.setupRepository(repo =>
repo.createDataSet(MyModel, {
onEntityAdded: ({ injector, entity }) => {
injector.logger.verbose({ message: `An entity added with value '${entity.value}'` })
},
authorizeUpdate: async () => ({
isAllowed: false,
message: 'This is a read only dataset. No update is allowed. :(',
}),
/** custom repository options */
}),
)
In the following example we've created a physical InMemory store for the model MyModel, and we've configured a Repository with a DataSet. It will log to a logger when an entity has been added and it won't allow us to update entities.
A DataSet is similar to a physical store, but it can have custom event callbacks and authorization logic. You can retrieve the dataset in a following way:
const dataSet = myInjector.getDataSetFor(MyModel)
dataSet.add(myInjector, { id: 1, value: 'foo' }) // <-- this will log to a logger
dataSet.update(myInjector, 1, { id: 1, value: 'bar' }) // <--- this one will be rejected
FAQs
Repository implementation for FuryStack
We found that @furystack/repository demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.