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

is-message

v1.0.2

Published

一个简单的nodejs消息体模块, 你可以安装它以建立更统一更便于阅读和维护的接口服务器

Downloads

4

Readme

is-message

一个简单的nodejs消息体模块, 你可以安装它以建立更统一更便于阅读和维护的接口服务器

安装教程

  1. 使用 npm install --save is-message 在项目中安装依赖.
  2. 在代码中使用引用这个依赖, 看上去他的样子应该类似于这样的 const message = require("is-message");
  3. 在需要使用的地方使用 new message() 的方式建立一个新的消息体. 然后即可使用相关API(方法)

相关API

  1. setStatus(status) --- 设置状态码, 必填项, 最基本的前端判断依据, 推荐使用HTTP的错误代码, 比如 200=请求成功;400=无效请求;403=缺少参数...等等
  2. setMessage(message) --- 设置消息内容, 建议作为必填项联合状态码使用, 比如"登陆成功","用户名不存在"..等等
  3. setData(data) --- 附加数据, 可空, 可以接任意数据, 比如 Object/Array/String/Number..主要场景在比如获取用户信息里, 用户信息数据存在这个里面
  4. setAccessToken(access_token) --- JWT模式, 设置access_token (1.0.2)
  5. setRefreshToken(refresh_token) --- JWT模式, 设置refresh_token (1.0.2)

完整参考

const message = require("is-message");
const msg1 = new message();
const msg2 = new message();

// 支持jQuery的那种链式写法, 让大家上手更亲切
msg1.setStatus(200).setMessage("获取用户信息成功").setData({name:"黄俊杰",sex:"男"});
// msg2效果和msg1一直, 仅仅是写法的问题
msg2.setStatus(200);
msg2.setMessage("获取用户信息成功");
msg2.setData({name:"黄俊杰",sex:"男"});