Giter VIP home page Giter VIP logo

snyk-dependency-checker's Introduction

Installing and running

To install dependencies from the command line run npm i To run, from command line run npm run dev To test, from command line run npm run test

To get package dependencies navigate to http://localhost:3000/packages/<packagename>/<version>/dependencies. Example: http://localhost:3000/packages/jws/4.0.0/dependencies

Note: I have used the typescript-express-starter to seed this product. This has allowed me to focus on the main logic. I do not endorse the structure this starter site has. I have not removed the existing code and just added bits that I required for the new endpoint.

The relevant code is in src/dependency-builder folder. Few infrastructure pieces for express are there in controllers and routes folder.

Implementation notes

  • Most of the heavy lifting here is done in dependency-builder.ts method buildDependencyGraph. It uses breath first tree traversal and tracks visited notes to avoid cycles.

  • This implementation currently lacks validation on input fields. This can be done with the validation middleware we have

  • The implementation only lists dependencies. I ignore devDependencies and peerDependencies.

  • The dependency graph contains a dependency only once (name + version) even if it has been used multiple times. Hence this dependency graph is not a true representation of nested dependencies. Instead this is above direct/indirect dependencies for the main package we are probing.

  • While I have added some tests, this needs some exhaustive testing and is missing integration and e2e tests.

    • I may have missed testing some type type of dependency hierarchy.
  • I use semver library to do dependency version resolution but have not tests all types of resolution. I am not sure if this solution works for git based or file dependency.

  • Improvements can also be made from a performance perspective

    • Current I have added rudimentary in-memory cache adapter for axios to cache npm registry responses (1 hour expiry)
      • While we can look at storing this in a data store, a hybrid approach can be to store data in store and a LRU cache to cache popular stuff in memory.
    • Currently the final calculated graph is not cached but it can be cached at express level. This will require us to define the cache eviction policy as underlying packages change.
  • From scaling perspective

    • The dependency graph is a good candidate for caching. We just need to determine the correct cache duration.
    • To effectively scale the applications servers, we can use external cache solutions like Redis to cache npm registry responses as well as our API responses. Again doing some LRU implementation if we need to manage costs.
    • Datastore can be blob or a key/value pair store.

snyk-dependency-checker's People

Contributors

chandermani avatar

Watchers

 avatar

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.