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

autharchy

v1.5.1

Published

proxied/saved/mocked environment to test and develop microservices

Downloads

12

Readme

autharchy

proxied/saved/mocked environment to test and develop microservices

Install

You can install it globally

npm -g autharchy

or as a dependency

npm -D autharchy

Companions

webapp

Browse the recent requests

server

Allow other to access your local services

Configuration

mkdir .autharchy

cd .autharchy

echo module.exports = {} > config.js

Main config

The file .autharchy/config.js will eventually allow to set default configuration for all the services. Currently it's not used.

Service

Create a folder for each service, with a config.js inside

Example

.autharchy/foo/config.js

module.exports = {
  type: 'REST',
  remote: 'https://example.com/api',
  local: {
    ip: '127.0.0.1',
    port: 5000,
  }
}

type (required)

The type of the service. The provided types are REST and graphql

Custom types can be added.

name

It defaults to the folder name.

It's used to determine the collection's name ${type}-${name}

In the example the name is 'foo' and the collection name is 'REST-foo'

remote

The url of the service that you want to proxy

It is not required if you are mocking all the endpoints from the database or a pre or post function.

local

Where to bind the local service.

  • local.ip defaults to '0.0.0.0
  • local.port defaults to 80

pre

(context) => context

it's executed just after matching the endpoint.

It can be used to modify the request that will be used to search on the database or to be sent to the proxy

It also can set a response, or modify the configuration.

Please refer to the service type documentation to further instructions regarding the context and the response

toQuery

[(context) => ({ some mongo query }), ...] | false

Requests are cached so after a first fetch you don't need the remote service to be up and running.

You can use pre to set context.conf.toQuery to false to disable the cache search

Otherwise it will loop the array running query after query until it returns a response.

Please refer to the service type documentation to further instructions regarding the defaults and the context schema regarding the request.

toDocument

(context) => document

You can use pre to set context.conf.toDocument to false to skip inserting the request and response in the database

Please refer to the service type documentation to further instructions regarding the defaults and the context schema regarding the request.

post

(context) => context

it's executed just before sending the response.

It can be used to modify the response that will be sent

Please refer to the service type documentation to further instructions regarding the context and the response

skipLogs

Requests are also logged, you can disable that setting skipLogs thuthy.

REST

Endpoints

If you want an specific configuration for a endpoint, you need to create a file whose name is the http method (or all), and the file path is the endpoint/ + the endpoint path

For instance: This file .autharchy/foo/endpoints/some/endpoint/GET.js will override .autharchy/foo/config.js when the request is a GET to /some/endpoint

You can use parameters between brackets.

For instance this file .autharchy/foo/endpoints/some/endpoint/[id]/all.js will override .autharchy/foo/config.js when a POST is sent to /some/endpoint/bar or when a GET is sent to /some/endpoint/buz

context

{
  "request": {
    "path": "",
    "params": {},
    "headers": {},
    "method": "",
    "body": {},
    "query": {}
  },
  "conf": {
    // ...foo/config.js,
    // ...foo/endoints/path/METHOD.js 
  },
  "response": {
    "status": 200,
    "headers": {},
    "body": {}
  }
}

graphql

Queries

If you want to override .autharchy/foo/config.js in some queries you can create any file at any path inside .autharchy/foo/queries/

For instance

.autharchy/foo/queries/bar.js

module.exports = {
  match: (context) => true // false 
}

It will loop over the files under queries/ until some match returns truthy

First one that matches, will override the configuration

context

{
  "request": {
    "headers": {},
    "method": "",
    "body": {},
    "query": {}
  },
  "conf": {
    // ...foo/config.js,
    // ...foo/queries/baz.js 
  },
  "response": {
    // the graphql response
  }
}