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 🙏

© 2026 – Pkg Stats / Ryan Hefner

sn-randpic

v0.1.0

Published

A Simple Random Pictures Service

Downloads

0

Readme

randpic

一个简易的随机图片服务,支持获取永久链接。

demo

demo here

config

配置文件在 src 目录的 config.ts,没有在根目录(甚至懒得在 tsconfig.json 加一笔)

下文的地址均以项目根目录作为相对目录起点。

  • server:指定监听的信息(目前仅支持端口)
    • port:监听端口
  • favicon?:就测试来看,Chrome 会默认获取 /favicon.ico 作为图标,而默认情况会随机返回图片作为图标,为了不出现这种情况,可以设置一个 favicon 的文件地址,默认以这个文件作为图标返回给浏览器,检测的条件是 pathname.startsWith('/favicon')
  • logLevel:同 pino,但是程序当中目前只用了 info error debug
  • cacheInMemorytrue代表先将所有文件读入再从内存返回,false则只保存路径,返回时从硬盘读。
  • allowDirectRequest:是否允许使用永久链接访问指定的图片,格式为 https://example.com/?filePath=/encoded/path/to/the/file,这个链接在默认情况下会包含在 Headers 中,名为 x-path。另外考虑用户可能会一时兴起想要保存图片链接,却没有打开控制台,因此设置了 Set-Cookie 头,会把路径保存在 prev 当中。
  • dataSource:获取原始图片文件的方式,默认会递归访问项目根目录下的 source 目录。
  • ExtHeaders:可以自定义额外的头信息(所谓额外,指除去了 Content-Type 这些不建议修改的),在这里修改 Headers 会覆盖 Cookiesx-path

scripts

"scripts": {
		"start": "node ./dist/index.js",
		"dev": "tsc && npm run start",
		"compile": "tsc",
		"pmstart": "pm2 start ./dist/index.js --log log.txt --name randpic"
	},
  • npm run start:执行 Typescript 编译后的文件。
  • npm run dev:编译源文件并执行。
  • npm run compile:仅编译不执行。
  • npm run pmstart:如果电脑上安装了 pm2 ,那么使用 pm2 来启动编译后的文件。若没有安装 pm2 不要用这个命令。