Skip to content

kellyvaughn/strapi--javascript-sdk

Repository files navigation

TAPROOM DESCRIPTION

This is a duplicated version of the no longer maintained strapi javascript sdk

Now you may be wondering...

Why duplicate a no longer maintained repository? And that's a question I asked myself, and due to this packages small size, and simple logic, it seemed faster to just duplicate this, throw it in a privde repo / npm package and iterate on it as we go.

We wll be extending upon the current semver set when the project siezed active maintenance.

If you end up using this package, please make sure to follow the same standards used in our Developer Guide when contributing.


Helpful Strapi Resources:


The official Strapi SDK for JavaScript, available for browsers or Node.js backends.


Install

npm install @taproom/strapi-sdk-javascript

Start now

New instance

import Strapi from '@taproom/strapi-sdk-javascript';

const strapi = new Strapi('http://localhost:1337');

Authentications

Local

await strapi.login('username_or_email', 's3cr3t');
// Redirect your user to the provider's authentication page.
window.location = strapi.getProviderAuthenticationUrl('facebook');

Once authorized, the provider will redirects the user to your app with an access token in the URL.

// Complete the authentication: (The SDK will store the access token for you)
await strapi.authenticateProvider('facebook');

You can now fetch private APIs

const posts = await strapi.getEntries('posts');

Files management

Browser

const form = new FormData();
form.append('files', fileInputElement.files[0], 'file-name.ext');
form.append('files', fileInputElement.files[1], 'file-2-name.ext');
const files = await strapi.upload(form);

Node.js

const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('files', fs.createReadStream('./file-name.ext'), 'file-name.ext');
const files = await strapi.upload(form, {
  headers: form.getHeaders()
});

Functions/Methods

Strapi(baseURL, storeConfig, requestConfig)

request(method, url, requestConfig)

register(username, email, password)

login(identifier, password)

forgotPassword(email, url)

resetPassword(code, password, passwordConfirmation)

getProviderAuthenticationUrl(provider)

authenticateProvider(provider, params)

setToken(token, comesFromStorage)

clearToken(token)

getEntries(contentTypePluralized, params)

getEntry(contentTypePluralized, id)

getEntryCount(contentTypePluralized, params)

createEntry(contentTypePluralized, data)

updateEntry(contentTypePluralized, id, data)

deleteEntry(contentTypePluralized, id)

searchFiles(query)

getFiles(params)

getFile(id)

upload(data)

requestConfig

Custom axios request configuration. See documentation

Resources

Roadmap

  • GraphQL
  • Attach/Detach entry relationship
  • Real time with Socket.io

Credits

License

MIT

About

No description or website provided.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published