https://github.com/lpreterite/express-sequelize-restful
Quickly use sequelize restful api on express
https://github.com/lpreterite/express-sequelize-restful
Last synced: 3 months ago
JSON representation
Quickly use sequelize restful api on express
- Host: GitHub
- URL: https://github.com/lpreterite/express-sequelize-restful
- Owner: lpreterite
- License: mit
- Created: 2017-11-17T09:05:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-29T07:42:51.000Z (almost 7 years ago)
- Last Synced: 2025-01-13T10:11:29.531Z (4 months ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-sequelize-restful
[](https://github.com/lpreterite/express-sequelize-restful) [](https://github.com/lpreterite/express-sequelize-restful/blob/master/LICENSE)
Quickly use sequelize restful api on express
## How to use
### install
```
$ npm i -S lpreterite/express-sequelize-restful
```### use
```
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const Router = express.Router;
const { RestfulMixin, operators } = require('express-sequelize-restful');app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencodedconst restful = new RestfulMixin({ prefix: '/user', constructor: Router });
const router = restful.parse({
operators: operators.sequelize,
model: model,
methods: ['fetch', 'select', 'find', 'create', 'update', 'patch', 'delete']
});app.use('/api', router);
const http = require('http').Server(app);
const PORT = 3000;
http.listen(PORT, function () {
console.log(`listening on *:${PORT}`);
});```