Giter Club home page Giter Club logo

cosmicjs-node's People

Contributors

atinux avatar dependabot[bot] avatar f1yn avatar flippedcoder avatar jazibsawar avatar joe2son avatar kgdiem avatar manimalik avatar nileshpatil-dev avatar pcwa-ahendricks avatar robinjayaswal avatar tonyspiro avatar waqasarshad777 avatar weewey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cosmicjs-node's Issues

Unhandled Errors in Fetch Promises

Curious why there is no catch on the fetches or any way to handle a reject. I think this is in most of the code, but I came across it looking at getObject.

  fetch(endpoint)
    .then(function(response){
      if (response.status >= 400) {
        var err = {
          'message': 'There was an error with this request.'
        }
        return callback(err, false);
      }
      return response.json()
    })
    .then(function(response){
      // Constructor
      var cosmic = {};
      var object = response.object;
      var metafields = object.metafields;
      if(metafields){
        object.metafield = _.keyBy(metafields, "key");
      }

If the resources does not exist, Cosmic returns a 404, which passes an error message back to my callback, but then continues to the next then() statement and errors out at response.object. Is there a way that I am supposed to halt the fetch() in my callback to prevent it from executing the final then() when there is an error ?

Published_at query

Hello all! I'd like to get my data filtering by published_at field but I guess that the field type is an String. Is that right? This is my query which is not working.

const data = await bucket.objects .find({ type: "publicacoes", published_at: { $gte: new Date("2021-01-10T10:03:46Z") } }).props("imagem,slug,content,metadata,published_at,title,excerpt") return data.objects;

Add better querying support

Currently, there seems to be no option for selecting the fields that should be included in the response during a getObject or seachObject call. To get a single metafield value from an object, the whole object needs to be downloaded. For simple objects, this doesn't add much overhead. But that's not the case when an object contains large descriptions, articles etc.
Similarly, should be able to select fields on connected objects too.

Failed to minify code

I'm using cosmicjs in a big React app created with create-react-app and I cannot build the project via npm run build without receiving this error:

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

 	./node_modules/cosmicjs/index.js:6 

Read more here: http://bit.ly/2tRViJ9

Now as the helpful link suggest this means the file is not pre-compiled and that seems to be true, so could you please publish the next version precompiled (if that is indeed the issue here)?

Also, is there anything I can do as a workaround, so that I can import coscmisjs and build the app like I can with any other npm module now? The build happens via CI, so precompiling it manually makes the whole thing more brittle than it should anyway.

I'm open for suggestions. Maybe I'm just doing something wrong myself.

deleteObject not working - returns 'object not found'

Seems like the api endpoint is getting the bucket_slug instead of the object slug and that's why it is returning 'Object not found'.

In line 272 bucket_config contains slug.

After changing that line to something like this return axios.delete(endpoint, { data: Object.assign(bucket_config, {slug: params.slug}) }) deleting was working. Probably it would also work if bucket slug is removed from config before adding it to data.

Cannot read properties of undefined (reading 'COSMIC_API_URL')

Hello,
I'm using Nuxt 3 (SSR) with Cosmic.JS and getting the following error:

Bildschirmfoto 2022-09-06 um 14 46 21

Here is my plugin I created unter plugins/cosmic.ts:

import Cosmic from 'cosmicjs'

const api = Cosmic();
const bucket = api.bucket({
  slug: process.env.COSMIC_JS_BUCKET_SLUG,
  read_key: process.env.COSMIC_JS_READ_KEY,
});

export default defineNuxtPlugin(() => ({
  provide: {
    cosmic: bucket
  }
}));

Maybe it's necessary to check if "process.env" is existing?

Node API for search

Hi,

Are there plans for extending this API for interacting with the /search endpoint? It currently looks like the getObjectType interface does not support this case.

Not able to get data to come back.

Hi, I have been trying to run your examples and I am not retrieving any data back to console.log out. It seems to never hit the callback... any ideas?

Update: Looks like its somewhere in the fetch(endpoint) call.

Potential braking change with the 4.2 version

Hello,

I was using 4.1 for almost 2 years ago, and my site started to crash last week, debugging my code I realized we stopped getting some of the nested data as we were expecting, I suppose there was a change in the cosmicjs api, I have a structure of nested objects in cosmic, something like this pages -> sections -> videos, the reason why my site started to crash is because of the data of the last object in my nesting chain was different, I was expecting an object with the whole data, instead of that, I was getting a string with just the id.

Before

{
   // rest of the page data,
  metadata: {
    sections: [
      {
        // rest of the object's metadata,
        video: {
          // whole video's metadata
        }
      }
    ]
  }
}

Before

{
   // rest of the page data,
  metadata: {
    sections: [
      {
        // rest of the object's metadata,
        video: '60d10806dd65e129d4f2870b' // just a single string
      }
    ]
  }
}

I updated the package to the latest version and I kept having this issue, this article says there are no breaking changes https://www.cosmicjs.com/changelog/npm-module-updates-v4-2, however, I had to change the implementation from bucket.getObjects to bucket.objects.find with the new specification, only after that, it worked as before again

sort not working for getObjects

In the docs there is a sort property for getObjects but it looks like that's missing in the source code.

After adding

if (params && params.sort) {
    endpoint += `&sort=${params.sort}`
}

it's working.

Is this missing or can I do sorting differently?
I can add these lines to be consistent with the docs.

Vulnerability in axios< 0.21.1

Source: https://www.npmjs.com/advisories/1594

Overview

The axios NPM package before 0.21.1 contains a Server-Side Request Forgery (SSRF) vulnerability where an attacker is able to bypass a proxy by providing a URL that responds with a redirect to a restricted host or IP address.

Remediation

Upgrade to 0.21.1 or later.

Getting media by folder not working

When I make the request to get a collection of media in a specific folder, it is returning all the most recent media for my current filter. Looking at the request, folder is not added to the query.

Is this functionality missing, or is there another way to get media folders returned?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.