npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

loanshub-shared

v1.0.0

Published

shared package for loanshub

Downloads

17

Readme

loansHub Shared

Purpose

I want to share typescript models between backend and frontend to reduce complexity and errors.

How to think about shared models

Priorities

  1. Use salestrekker enums where possible. Eg the applicant's title field would use the salestrekker enum value as they are 1:1 mapped.
  2. If the value doesn't flow through to salestrekker, export the enum from the App directory instead.

Applying changes to Models

In the shared project:

  1. Make your changes to the models
  2. Run npm run build so that dependant projects can refer to these new models
  3. Projects that bundle this dependency (eg functions) need to re-pack their bundle, and then re-install this new bundle

Depending on this project

Web applications can simply import these models, but Firebase functions that depend on this project need a bit more work.

Firebase functions

The Google Cloud platform downloads your dependencies from npm when functions are deployed, but the loanshub-shared module only exists locally and isn't accessible.

So we package the module at build-time so that its included in the deployment, and we tell the project to use this packaged dependency rather than the local one.

Notice in the functions project's package.json:

  • the build script calls npm run pack-loanshub-shared
  • the update-models script repacks the dependency and reinstalls from the package
  • the dependency for loanshub-shared is a .tgz file rather than a package name

When the functions project builds, pack-loanshub-shared is called to package up the loanshub-shared module in the ./shared directory into a .tgz file, so that the local dependency is uploaded to the cloud when deploying.

Salestrekker Typings

To update Salestrekker typings after an API update on their side:

  • Download the GraphQL schema from the salestrekker API playground

  • Then use this tool to convert to Typescript with the following config:

generates:
  types.ts:
    plugins:
      - typescript
    config:
      skipTypename: true
      namingConvention: keep
  • It may generate some enums with a dodgy enum that's REALLY long, you'll need to prune these before building

  • Then build the shared project and run update-models in the functions project, and resolve any typescript issues