Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Ephery is a dead simple, in-memory, client-side, fake API service. This tool is useful for prototyping client-side applications without hijacking Ajax. In particular, this tool was built to interact with React + Redux applications that rely on an API service, but Ephery can be useful for any framework that isn't too opinionated on data-fetching.
npm install --save ephery
Define some basic schemas and fixtures.
// src/services/store.js
import Store from 'ephery';
const schemas = {
user: {
attributes: {
name: true,
email: true,
},
relationships: {
blogs: {
hasMany: 'blog',
},
comments: {
hasMany: 'comment',
},
},
},
blog: {
attributes: {
title: true,
createdAt: true,
},
relationships: {
author: {
belongsTo: 'user',
},
comments: {
hasMany: 'comment',
},
},
},
comment: {
attributes: {
text: true,
createdAt: true,
},
relationships: {
user: {
belongsTo: 'user',
},
blog: {
belongsTo: 'blog',
},
},
},
};
const fixtures = {
user: {
1: {
name: 'John Doe',
email: 'johndoe@gmail.com',
blogs: ['1'],
comments: ['1'],
},
},
blog: {
1: {
title: 'Tabs vs. Spaces',
author: '1',
comments: ['1'],
},
},
comment: {
1: {
text: 'First comment!',
user: '1',
blog: '1',
},
},
};
export default new Store(schemas, fixtures);
Then somewhere in your application, you can invoke Ephery. All returned data is deeply nested JSON.
import api from '../services/store';
api.fetch('user', '1').then(user => {
/*
{
name: 'John Doe',
email: 'johndoe@gmail.com',
blogs: [{
id: '1',
title: 'Tabs vs. Spaces',
author: '1',
comments: ['1'],
}],
comments: [{
id: '1',
text: 'First comment!',
user: '1',
blog: '1',
}]
}
*/
});
async
api.create('user', {
name: 'Dylan',
email: 'dylan@gmail.com',
}).then(user => {
});
async
api.fetch('user', '1').then(user => {
});
async
api.find('user', {
name: 'Dylan',
}).then(users => {
});
async
api.update('user', '1', {
name: 'Bob',
}).then(user => {
});
async
api.del('user', '1').then(success => {
// true or false
});
Dan Abramov has an excellent course on Egghead.io titled "Idiomatic Redux," where he mocks a simple API service that is invoked by actions. Ephery can act as that service in applications that have more intensive CRUD requirements. Because Ephery returns deeply-nested JSON objects, responses can be easily normalized and merged with the state tree.
You'll need to create your own production-grade API service once your backend is finished, but Ephery can act as a drop-in replacement until then.
Relationships do not cascade right now. Meaning, if you delete a user
entity that a blog's author
relationship (a belongsTo
relationship) points to, the blog
is not deleted. I'm going to add this functionality soon. Also, if you're using Normalizr, you'll essentially have to duplicate schema definitions.
Also, the coverage could be a lot better, so more tests are coming as well.
FAQs
Dead simple, in-memory, client-side, fake API service.
The npm package ephery receives a total of 9 weekly downloads. As such, ephery popularity was classified as not popular.
We found that ephery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.