![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@webeetle/core-sdk
Advanced tools
Core SDK is a small library that help you to build your own SDK in your Javascript Application.
Start to create your SDK is really simple.
import SDK from '@webeetle/core-sdk'
const sdk = new SDK()
Now you have an instance of your sdk. Basicly you now have a sdk.req
. This property defined is an instance of axios
library. Check out how to use it here.
In addition to having the property, you will have a set of functionality such as:
decorate
: you can decorate your sdk instance with your functionalities.
log
: you have a predefined logger.
addClient
: allow you to add axios
based client configuration.
addService
: allow you to add plugin to your instance.
You can pass to the core-sdk
constructor a set of options:
name
: the name of your sdk.
clients
: a key value object where the key represent the name and the value is an object that represent an axios
client configuration.
logLevel
: one of info
, warn
, error
(predefined), trace
.
import SDK from '@webeetle/core-sdk'
const mySdk = new SDK({
name: 'WeBeetle SDK',
clients: {
v1: {
baseUrl: 'http://api.webeetle.com/v1',
headers: {'Authorization': 'Bearer 12333321122222'}
},
v2: {
baseUrl: 'http://api.webeetle.com/v2',
headers: {'Authorization': 'Bearer 44443322222222'}
}
},
logLevel: 'info'
})
Perfect now yoou have your configured sdk instance. If you have the necessity to invoke an endpoint on the v1
api version you can simply:
mySdk.v1.post('/your/endpoint')
.then(response => {
// Do something useful here
})
.catch(e => {
// Manage the error
})
or if you want to use v2
api in an async
function:
async function myUtilityFunction () {
try {
const response = await mySdk.v2.post('/your/endpoint')
// Do something userful here
} catch (e) {
// Manage your error here
}
}
The API of your sdk instance allows you to add new properties that you can use everywhere in your application. Here an example:
import SDK from '@webeetle/core-sdk'
const mySdk = new SDK()
mySdk.decorate('sum', (a, b) => a + b)
and somewhere else in your application you can use it as follow:
const total = mySdk.sum(5, 30)
With the decorate API you can store everything you want. For example a configuration object.
The core-sdk
api expose another method that allow you to expose a service. For example, if you need to expose a set of functionality to manage users (create, update, delete) you can create a service, and decorate the main sdk instance. Below an example:
// file users.js
import { plugin } from '@webeetle/core-sdk'
export default plugin((instance, name) => {
instance.decorate(name, {
create: async userData => {
// create you user
},
getUserByUsername: async username => {
// get user by username
},
update: async userData => {
// update your user
},
delete: async username => {
// delete your user
}
})
})
// file mySdk.js
import SDK from '@webeetle/core-sdk'
import users from '/path/to/users'
const mySdk = new SDK()
mySdk,addService('users', users)
// now we can use it
mySdk.users.create({
name: 'Davide',
username: 'davide'
})
.then(response => {
// do something
})
.catch(e => {
// do something
})
If you feel you can help in any way, be it with examples, extra testing, or new features please open a pull request or open an issue.
The code follows the Standard code style.
Simply run npm run test
from command line.
This project is kindly sponsored by Webeetle s.r.l.
Licensed under MIT.
FAQs
Core SDK
The npm package @webeetle/core-sdk receives a total of 3 weekly downloads. As such, @webeetle/core-sdk popularity was classified as not popular.
We found that @webeetle/core-sdk 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.