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

restify-seed

v1.0.0

Published

npm install restify-curd

Downloads

4

Readme

npm restify 模块种子

Installation

npm install restify-curd

使用

restify = require 'restify'
mongoose = require 'mongoose'
curd = require 'restify-curd'

server = restify.createServer()
db = mongoose.createConnection 'mongodb://localhost/restify-curd-test'
db.once 'open',->
    curd (server,db,modelName,schemaConfig,options)
    server.listen port,->
        console.log 'server start.'

参数

  • server object
  • db object
  • modelName string,collection名称
  • schemaConfig object,schema对象
  • options object

options参数

  • list boolean 是否开放获取列表接口,默认开放
  • post boolean 是否开放新建接口,默认开放
  • get boolean 是否开放获取详情接口,默认开放
  • put boolean 是否开放修改接口,默认开放
  • patch boolean 是否开放修改接口,默认开放
  • del boolean 是否开放删除接口,默认开放

其他默认设置

  • 默认为schemaConfig添加createAt和random两个数字类型数字,一个标识创建资源的时间,一个为小于1的随机数字,用于获取随机数据。

GET /collection 获取列表

参数:

  • limit number
  • page number
  • sortby string 默认按createAt大小逆序排列
  • desc asc/desc
  • fields string 逗号分隔的字符串 返回:
  • count number
  • page number
  • limit number
  • sortby string
  • desc asc/desc
  • list array

POST /collection 新建

返回新建的记录

GET /collection/:id 查询指定id的记录

参数:

  • fields string 逗号分隔的字符串

PUT /collection/:id 更新指定id的记录

返回该记录信息

PATCH /collection/:id 修改指定id的记录

返回该记录信息

DELETE /collection/:id 删除指定id的记录