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

@tangbin/node-util

v1.0.0

Published

服务器端的辅助函数库

Downloads

1

Readme

@tangbin/node-util

服务器端的辅助函数库

Install

#npm
npm install --save @tangbin/node-util
#yarn
yarn add @tangbin/node-util

Usage

Interface & Type

@types 目录中中定义了通用的数据类型 Interface 和 Type 以供使用。

/**
 * 用户中心关系图(包含关系)
 *
 * 部门 => 角色
 * 用户 => 部门 => 角色
 * 平台 => 菜单
 * 权限 => 角色 + 平台 + 菜单
 */
import { ResponseData } from '@tangbin/node-util/@types';
import { Permission } from '@tangbin/node-util/@types/permission';

常量

constants 目录中中定义了常用的常量,后续会不断添加和完善。

import {
  GET,
  POST,
  FETCH_REQUEST_NAME,
} from '@tangbin/node-util/constants/request';
import { SUCCESS_CODE } from '@tangbin/node-util/@types/constants/response-code';

middleware

middleware 目录中中定义了常用的中间件,后续会不断添加和完善。

import methodInterceptor from '@tangbin/node-util/middleware/method-interceptor';

CURD 辅助方法

routes 目录中包含一系列辅助方法,用于简化数据库增删改查操作。

import { add, batchDel, del, fetch, query, update } from '../model/student';

import {
  commonAdd,
  commonBatchDelete,
  commonDelete,
  commonFetch,
  commonQuery,
  commonUpdate,
} from '@tangbin/node-util/middleware/routes/mysql-curd-helper';

import {
  ADD_REQUEST_NAME,
  BATCH_DELETE_REQUEST_NAME,
  DELETE_REQUEST_NAME,
  FETCH_REQUEST_NAME,
  QUERY_REQUEST_NAME,
  UPDATE_REQUEST_NAME,
} from '@tangbin/node-util/constants/request';

// fetch
router.post(FETCH_REQUEST_NAME, (req, res, next) => {
  commonFetch<Student>(req, res, next, fetch);
});

// add
router.post(ADD_REQUEST_NAME, (req, res, next) => {
  commonAdd(req, res, next, add);
});

// update
router.post(UPDATE_REQUEST_NAME, (req, res, next) => {
  commonUpdate(req, res, next, update);
});

// query
router.get(QUERY_REQUEST_NAME, (req, res, next) => {
  commonQuery(req, res, next, query);
});

// delete
router.get(DELETE_REQUEST_NAME, (req, res, next) => {
  commonDelete(req, res, next, del);
});

// batch delete
router.post(BATCH_DELETE_REQUEST_NAME, (req, res, next) => {
  commonBatchDelete(req, res, next, batchDel);
});