Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@drieam/common

Package Overview
Dependencies
Maintainers
4
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@drieam/common

Default Drieam api wrapper

  • 6.7.1
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by200%
Maintainers
4
Weekly downloads
 
Created
Source

npm

@drieam/common

This package include some utilities used by Drieam LTI apps.

Table of Contents

Getting Started

Installation

Install the @drieam/common and its dependencies.

yarn add @drieam/common @drieam/api @drieam/models @drieam/ui

Usage

import { connectActions, connectReducers } from "@drieam/api";
import { User } from "../models";
import { setStore } from "@drieam/common";

type API = {
  user: User
};

type Store = RootReducer<{
  api: ConnectReducers<API>
}>;

const api: ApiRoutes<API> = {
  user: {
    onError,
    path: "/lti/proxy/api/v1/users/:id?",
    mapper: User,
    list: true
  }
};

const actions = connectActions < API > api;
const rootReducer = connectReducers < API > api;
const store = setStore(
  api,
  rootReducer,
  [
    /** EMPTY MIDDLEWARES **/
  ],
  defaultOptions
)({
  /* EMPTY INITIAL STATE */
});

Read the full API Documentation

Components

setStore(...) => Store

Create a redux store.

  • Arguments:
    1. api (ReactRoutes): Rest API configuration.
    2. rootReducer (Reducer): Root combined reducers.
    3. extraMiddlewares (Middleware[]): Array of redux middlewares.
    4. options (object): Configuration options.
import { setStore } from '@drieam/common';
...

type Store = RootReducer<{
  api: ConnectReducers<API>;
}>;
...
const store = setStore(
  api,
  rootReducer,
  [/** EMPTY MIDDLEWARES **/],
  defaultOptions,
)({
  /* EMPTY INITIAL STATE */
});
  • Return Store: The redux store.

Options

General settings of an action as an extension of api actions.

{
  withErrorHandler: true,
  csrfToken: getCSRFToken(),
  history: createBrowserHistory(),
  toasts: {
    offline: {
      duration: 0,
      message: 'Not connected.',
    },
    save: { message: 'Saved success.' },
    delete: { message: 'Deleted success.' },
  },
};
}
  • Attributes:
    1. withErrorHandler (boolean): Enables ErrorHandlingMiddleware (Default: true). Provides feedback through an Antd Notification on offline, save success or fail action.
    2. toasts (object): Notification settings, you can express which message can be provided by the error handler.
    3. history (object): history is a JavaScript library that lets you easily manage session history anywhere JavaScript runs. (default: require 'history').
    4. csfrToken (string): Cross-site request forgery token. (Default: <meta [name="csrf-token"] />).
    5. Api options

FAQs

Package last updated on 23 Apr 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc