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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@antcde/connect-ts

v0.4.15

Published

Helper to connect to the ANT api

Readme

ANTCONNECT TS/JS

With this package you can give your applications simple access to the ANT api

install npm package

npm install axios

axios is needed and not included in the package itself

npm install ant_tsconnect

this will give you access to the AntConnect class which needs a httpClient (see below)

httpclient

to connect to one of ANT's environments you need a httpclient where you set the following properties

  • client_id
  • client_secret
  • base_url
  • api_url
  • this client you will pass on to AntConnect, and you can connect to the given api
const httpClient = new CustomHttpClient('http://api-antcde.io', '/api/1.0', 'X', 'SECRET')
const antConnect = newAntConnect(httpClient)

Authentication

to authenticate an user you can access the authenticate method by the following

antConnect.httpClient.authenticate({
  username: '[email protected]',
  password: 'password'
})

you can save the access token to localstorage or a cookie and add it with the custom interceptors to each request (see below)

two-factor authorization (2fa)

if 2fa is enabled for the user you will receive error response with data

{ code: 1707747196 }

in

antConnect.users.getAuthenticatedUser()

In that case the best way is handling this error in custom interceptor by the error code and verify your login token with the prepared request from antConnect

antConnect.users.verifyTwoFactor({ code })

interceptors

it is possible to create custom request and response interceptors.

you can create a custom class with the following functions:

// Custom request interceptor
export function requestInterceptor(config) {
  config.headers = {}

  config.headers['Authorization'] = 'Bearer Client'
  return config
}

// Custom response interceptor
export function responseInterceptor(response) {
  // Modify the response as needed
  // For example, you can extract specific data or handle errors
  return response
}

then you can add these interceptors to the httpclient

import { requestInterceptor } from '@/interceptors' // import

const httpClient = new CustomHttpClient(
  'http://192.168.1.50:8000',
  '/api/1.0',
  '2',
  'OEQWm6a4rsbqTSEiB2y32O2yR0J3MFlUPbZJWI9w'
)
httpClient.addRequestInterceptor(requestInterceptor) // add here
const antConnect = newAntConnect(httpClient)

create single instance

Depending on your framework there are multiple ways to create a single instance of AntConnect across your whole application

Vue (3)

// TODO change this

const httpClient = new CustomHttpClient(
  'http://192.168.1.50:8000',
  '/api/1.0',
  '2',
  'OEQWm6a4rsbqTSEiB2y32O2yR0J3MFlUPbZJWI9w'
)
httpClient.addRequestInterceptor(requestInterceptor)
const antConnect = newAntConnect(httpClient)

app.provide('antConnect', antConnect) // here we provide the instance to the whole application

and by injection in our vue components we can access the instance like this:

const antConnect = inject('antConnect')
let projects = await antConnect.projects.getProjects()

in the above example we fetch the projects of a given user.

As we have an idea to move all projects to monorepo, maybe will be better to move to pnpm packager