How to use kinto-http - 6 common examples

To help you get started, we’ve selected a few kinto-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kinto / formbuilder / formbuilder / actions / server.js View on Github external
function initializeBucket() {
  const api = new KintoClient(
    config.server.remote,
    {headers: getAuthenticationHeaders(uuid.v4())}
  );
  return api.createBucket(config.server.bucket, {
    safe: true,
    permissions: {
      "collection:create": ["system.Authenticated",]
    }
  }).then(() => {
    api.bucket(config.server.bucket).setPermissions({
      "write": []
    },
    {patch: true}); // Do a PATCH request to prevent everyone to be an admin.
  })
  .catch(() => {
    console.debug("Skipping bucket creation, it probably already exist.");
github Kinto / formbuilder / formbuilder / actions / server.js View on Github external
const form = getState().form;
    const schema = form.schema;
    const uiSchema = form.uiSchema;

    // Remove the "required" property if it's empty.
    if (schema.required && schema.required.length === 0) {
      delete schema.required;
    }

    dispatch({type: FORM_PUBLICATION_PENDING});
    const adminToken = uuid.v4().replace(/-/g, "");
    const formID = getFormID(adminToken);

    // Create a client authenticated as the admin.
    const bucket = new KintoClient(
      config.server.remote,
      {headers: getAuthenticationHeaders(adminToken)}
    ).bucket(config.server.bucket);

    // The name of the collection is the user token so the user deals with
    // less different concepts.
    bucket.createCollection(formID, {
      data: {schema, uiSchema},
      permissions: {
        "record:create": ["system.Authenticated"]
      }
    })
    .then(({data}) => {
      dispatch({
        type: FORM_PUBLICATION_DONE,
        collection: data.id,
github Kinto / kinto-admin / test-browser / utils.js View on Github external
export function createClient(username, password) {
  return new KintoClient("http://0.0.0.0:8888/v1", {
    headers: {
      Authorization: "Basic " + btoa(`${username}:${password}`),
    },
  });
}
github Kinto / kinto-admin / src / client.js View on Github external
export function setupClient(auth: AuthData): KintoClient {
  const { server } = auth;
  return setClient(
    new KintoClient(server, {
      headers: { Authorization: getAuthHeader(auth) },
      timeout: 30000,
      retry: 1,
    })
  );
}
github adngdb / processeer / client / src / db.jsx View on Github external
return Promise.resolve().then(() => {
        const headers = {};
        if (userToken) {
            headers.Authorization = `github+Bearer ${userToken}`;
        }

        const db = new KintoClient(
            `${process.env.STORAGE_ENDPOINT_URL}/v1`,
            { headers }
        );
        const bucket = db.bucket('processeer');

        collections.blocks = bucket.collection('blocks');
        collections.reports = bucket.collection('reports');
    });
}
github Common-Voice / sentence-collector / shared / db.js View on Github external
constructor(remote, username, password) {
    this.username = username;
    this.password = password;

    const defaultOptions = {
      remote,
    };

    if (username && password) {
      defaultOptions['headers'] = {
        Authorization: "Basic " + btoa(`${username}:${password}`),
      };
    }

    this.server = new KintoClient(remote, defaultOptions);
    this.user = new User(this.server, username);
    this.sentences = new Sentences(this.server, username);
    this.cvSentences = new CVSentences(this.server, username);
  }

kinto-http

JavaScript HTTP client for the Kinto API.

Apache-2.0
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular kinto-http functions