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

nideriji-api

v0.3.1

Published

API of Nideriji and Ohshenghuo.

Downloads

5

Readme

nideriji-api

第三方你的日记 Web API

npm · nideriji-api-server

简介

基于你的日记网页版的第三方 API 的 Node.js 实现,基于 axios,支持 Typescript

使用

首先你需要安装 Node.js 和一个包管理器,以下以 yarn 为例:

yarn add nideriji-api

然后在你的项目中导入该模块,即可使用:

import Nideriji from "nideriji-api"; 

模块自带 Typescript 支持,无需安装 @types/nideriji-api。~~也没有这个包~~

使用范例见 play 分支或者此分支下的 test/index.ts。~~它们可能并不完整~~

简要说明

发起网络请求的方法均为包装的 axios 请求,调用后会返回 Promise<AxiosResponse> 以进行进一步的处理。

  • Nideriji.login 发起登录请求;如果登录成功则自动存储 Token 到实例中
  • Nideriji.diary 下的方法实现 Web 对于日记的各种增删查改
  • Nideriji.instance 返回此模块包装的 axios 实例
  • Nideriji.config 对此模块的一些行为进行配置
  • Nideriji.setHost 设置后端服务的地址,默认值为 https://nideriji.cn/api

对于返回的 AxiosResponse,可以参考 Axios 官网

在前端项目中使用

由于源服务器没有支持 CORS,所以直接在前端项目如 React 项目中使用本项目会引发 CORS 错误。目前对于这种问题的解决方法使使用代理服务器;

本仓库的 server 分支包含了一个使用 Next.js 云函数进行代理的简单的代理服务器,可以在 Vercel 上部署之后,使用上面提到的 Nideriji.setHost 方法修改服务地址为代理地址之后再使用。

nideriji-api-server 的 Demo:https://nideriji-api-server.vercel.app/

附录

纯纯的图一乐。只是不太喜欢官方的 Web 版。