npm.io
0.6.0 • Published 3 years ago

@izzle-org/crud-io

Licence
MIT
Version
0.6.0
Deps
3
Size
14 kB
Vulns
0
Weekly
0

Izzle Crud IO JS Lib

Simple Crud Service Lib, based on OAuth2 Authorization and Axios Calls

Installation

Using npm:

$ npm i -g npm
$ npm i @izzle-org/crud-io

Usage

My Crud Service 'product.service.js'

import { CrudService } from '@izzle-org/crud-io'

export default class extends CrudService {
    constructor () {
        super('products')
    }
}

index.js

import { ApiService, JwtService } from '@izzle-org/crud-io'

// Handle OAuth2
...
// JWT Config
JwtService.encrypt = true
JwtService.secretKey = 'foobar123'
JwtService.useSessionStorage()

JwtService.setToken({ access_token: 'foobar' })

// API Config
ApiService.init('https://api.foo.bar')
ApiService.setAuthHeader('Bearer ' + JwtService.getToken().access_token)

import ProductService from './product.service.js'

const service = new ProductService()

// GET https://api.foo.bar/products with Authorization Header (Bearer foobar)
let products = service.list()

License

Copyright (c) 2020-present Daniel Böhmer

MIT License

Keywords