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

narvin-tpt-sdk

v0.6.3-0

Published

## Requirements

Downloads

3

Readme

narvin-tpt-sdk

Requirements

  • Node.js + npm. Versions are defined in ./package.json and .nvmrc.

How to use?

Import whatever you need from narvin-tpt-sdk module eg.

import { AuthorService } from 'narvin-tpt-sdk';

new authorService() = new AuthorService();

const author = authorService.getOne();

If you need some developers tools you can import them from narvin-tpt-sdk/dev eg.

import { AuthorMockService } from 'narvin-tpt-sdk/dev';

new authorMockService() = new AuthorMockService();

const author = authorMockService.getOne();

Structure

SDK is devided into:

  • core - place for config, errors, requests logic. Mostly for internal usage.

  • domain - here we should place all our domain related logic. Every domain can consist of:

    • services/ - directory where we put all domain related services. Each Service should use standarised protocol for communication:
      • Be class based
      • Make use of FailedResult and CorrectResult types as an return value from function
    • repository.ts - file where we fetch data.
    • factory.ts - place where we create our models.
    • schemas.ts - file where we defined zod schemas which are used during fetching.
    • types.ts - place to define our models/schema types.
    • errors.ts - fiel to define custom errors.
    • index.ts - entry file to our domain. We should only export elements which should be publicly available.
    • index.dev.ts - entry file to our domain but only for developer purposes only.
  • utils - place for internal, not domain specific utils.

API docs

Basic information about API is available here.

Q&A

  • Why we don't use class based models? - We are using typed plain object instead of contstructed ones (new Modal()) as models, because of React Server Components limitation which is forbidding use of them (serialization problem).
  • How to develop locally? - Use npm link here and npm link narvin-tpt-sdk in your project directory.
  • How to publish? - Login to company account via npm login, create new version with npm version and publish via npm publish

TODO

  • Translate error messages?
  • Refactor apiRequest function
  • Handle 204 apiRequest better (problem with missing schema)
  • Split to smaller modules?
  • Move error codes to static property of services
  • Watch for cycle dependencies -> author <==> article
  • Split author and category schema between detail and collection ones. In detail we will have articles, in collection not