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

express-mysql-restful-generator

v1.0.10

Published

generate files for restful api and admin page for mysql, all generated, all under control, with admin page!

Downloads

12

Readme

express-mysql-restful-generator(名字有点长,求测字起名)

给每个表生成对应的restful接口文件,作为Router使用在你的express项目中。|generate files for restful api for each table, require them as routers and use in your app

  • 可用于现有的express项目|designed for an working express
  • 所有的逻辑都是生成的,都可以改|more flexable

用到的项目|related projects

  • bookshelf.js http://www.bookshelfjs.org/
  • ng-admin https://ng-admin-book.marmelab.com/

如果不是现有的项目,就新建一个|prepare a working express if you don't have one

mkdir myproj
cd myproj
npm init
npm install express --save
vi app.js #copy code into app.js
node app.js

app.js

var express = require('express');
var app = express();

// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
  res.send('hello world');
});

app.listen(80)

使用本项目生成restful代码|use this to generate code

npm install express-mysql-restful-generator --save
node node_modules/express-mysql-restful-generator/cli.js
#path_for_generated_files
#host
#user
#password
#db
#done!
vi app.js

应用这些生成的代码|use generated code

app.js


var express = require('express');
var app = express();
app.use('/restful',require('./restful/default-router'))
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
  res.send('hello world');
});

app.listen(80)

定制情况(自由发挥)|cases

//default
app.use('/restful',require('./restful/default-router'))

//only table
app.use('/table1',require('./restful/routers/table1')))

定制Router的实现(具体修改自由发挥)|customize table router/actions

vi path_for_generated_files/table_name #and modify it

默认的restful规则|restful standard

  • listView => GET /users
  • creationView => POST /users
  • showView => GET /users/:id
  • editionView => PUT /users/:id
  • deletionView => DELETE /users/:id

/restful/test_table/1

  {"id":1,"name":"2017-01-13 12:56:25"}

后台管理页面|admin page

/restful/admin/

  • using ng-admin https://github.com/marmelab/ng-admin