Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@drieam/api
Advanced tools
@drieam/api is middelware for redux. This library handles async AJAX request against Drieam or Canvas Restful APIs.
$ yarn add @drieam/api redux
import { Base } from '@drieam/api';
class User { public id: number; public name: string; }
export type API = { users: User };
const apiRoutes: ApiRoutes<API> = {
users: {
path: '/lti/proxy/api/v1/users/:id?',
mapper: User,
list: true,
options: {
onError: (action) => { console.error(action.response.error) },
}
},
};
import * as api from '@drieam/api';
import { combineReducers } from 'redux';
import { apiRoutes, API } from './api';
export const rootReducer = combineReducers({
api: api.reducers.connect<API>(apiRoutess),
});
import { createStore, applyMiddleware } from 'redux';
import * as api from '@drieam/api';
import { apiRoutes } from './api';
import rootReducer from './reducers/index';
const store = createStore(rootReducer, applyMiddleware([...api.apiMiddlewares(apiRoutes, /* options */)]));
import * as api from '@drieam/api';
import { API } from './api';
const base = api.actions.connect<API>(apiRoutes, options);
dispatch(base.users.fetchEntity(1))
Routing Structure is base of a key-value object where you can configure your basic reducer structure for use cases where you need to fetch data from Rest APIs. This structure is base on a type and a Hash object from that type.
{ path: '/lti/proxy/api/v1/users/:id?' }
{
path: path => [
'/api/v1/categories',
path.id && path.id,
path.sorting && 'sort'
].filter(Boolean).join('/');
}
}
{ mapper: User } // User is a class
{ mapper: data => data }
Note: Whether
list
orentity
should be defined. If both are not defined or false,redux
will complaint with an error.
{ entity: true, list: true }
{ list: (state, action) => { return state } }
'id'
): collection's unique key.'append'
) Order of insertion a listState.'PUT'
) Set the default update method.'same-origin'
) The request credentials you want to use for the request: omit
, same-origin
, or include
. To automatically send cookies for the current domain, this option must be provided.'Attributes'
) A string to transform the collection name before sending.{}
) HTTP headers allow the client and the server to pass additional information with the request or the response. An HTTP header consists of its case-insensitive name.redux-form
) Return a specific submission error format.
antd
: Antd Forms error format.final-form
: Final-form error format.redux-form
: Redux-form error format. (Deprecated)false
: default by the api.Creates an object
structure with all the redux actions needed for each resource definition.
const actions = api.actions.connect<{ users: any }>(api);
This action refresh the data in the reducer.
This page is added in the reducer.
fetchPage({ page: 'next' })
.attributes
can be one or many and it will be update per id position. Ex: actions.user.saveList([1, 2], { name: 'Peter' });
Creates an object
structure with all the redux actions needed for each resource definition.
const apiReducers = api.reducers.connect<{ users: any }>(api);
{
pending: boolean = false // True if data is still being loaded for the first time.
fulfilled: boolean = false // True if data was loaded successfully.
rejected: boolean; = false // True if data was loaded unsuccessfully.
settled: boolean; = false // True if the data load completed, if successfully or unsuccessfully.
value: T | null = null // Value of successfully loaded data; otherwise, null.
reason: string = null // Error of unsuccessfully loaded data; otherwise, null
status: number = null // Last HTTP [status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes).
}
We welcome all contributors who abide by our Code of Conduct. Please see the Contributors Guide for more details on submitting a PR, setting up a local dev environment, running tests, etc...
Until this project reaches a 1.0 milestone, minor version numbers will simply be incremented during each release. The Changelog will continue to document the different types of updates, including any "breaking changes".
After the 1.0 milestone, this project will follow SemVer.
FAQs
Default Drieam api wrapper
We found that @drieam/api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.