{"id":21659161,"url":"https://github.com/sequelize/sequelize-restful","last_synced_at":"2025-07-17T22:31:29.669Z","repository":{"id":6124585,"uuid":"7352758","full_name":"sequelize/sequelize-restful","owner":"sequelize","description":"A connect module that adds a restful API for all defined models to your application.","archived":true,"fork":false,"pushed_at":"2018-05-12T17:01:15.000Z","size":54,"stargazers_count":294,"open_issues_count":10,"forks_count":58,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-11-01T05:34:27.425Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sequelize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-28T09:49:55.000Z","updated_at":"2024-04-09T18:24:51.000Z","dependencies_parsed_at":"2022-08-30T18:30:50.239Z","dependency_job_id":null,"html_url":"https://github.com/sequelize/sequelize-restful","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequelize%2Fsequelize-restful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequelize%2Fsequelize-restful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequelize%2Fsequelize-restful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sequelize%2Fsequelize-restful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sequelize","download_url":"https://codeload.github.com/sequelize/sequelize-restful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226305642,"owners_count":17603855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T09:30:36.275Z","updated_at":"2024-11-25T09:32:00.953Z","avatar_url":"https://github.com/sequelize.png","language":"JavaScript","readme":"# sequelize-restful [![Build Status](https://secure.travis-ci.org/sequelize/sequelize-restful.png)](http://travis-ci.org/sequelize/sequelize-restful)\n\nA connect module based on a fork of sequelize-restful that adds a one level of associative capability to a restful API. It also lets you define which model should be exposed through this restful API.\n\n## Unmaintained\n\nThis project is not actively developed/maintained. As a result of that, you won't be able to create issues any longer. I will happily merge pull requests, though. Please consider using [finale](https://github.com/tommybananas/finale) or [epilogue](https://github.com/dchester/epilogue).\n\n## Usage\n\n```js\nvar express   = require('express')\n  , Sequelize = require('sequelize')\n  , http      = require('http')\n  , restful   = require('sequelize-restful')\n  , sequelize = new Sequelize('database', 'username', 'password')\n  , app       = express()\n\n// define all your models before the configure block\n\napp.configure(function() {\n  app.use(restful(sequelize, { /* options */ }))\n})\n\nhttp.createServer(app).listen(app.get('port'), function(){\n  console.log(\"Express server listening on port \" + app.get('port'))\n})\n```\n\n## Options\n\n```js\n{\n  // Parameter:   endpoint\n  // Description: Define the path to the restful API.\n  // Default:     '/api'\n\n  endpoint: '/restful',\n\n  // Parameter:   allowed\n  // Description: Define which models will be exposed through the restful API\n  // Default:     'new Array()' if it is an Empty array, all the models will be exposed by default\n\n  allowed: new Array('Model0', 'Model1', 'Model2')\n}\n```\n\n## The API\n\n### GET /api\n\nReturns a list of all declared models\n\n```console\n$ curl http://localhost:3000/api\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": [\n    {\n      \"name\": \"Tag\",\n      \"tableName\": \"Tags\"\n    },\n    {\n      \"name\": \"Image\",\n      \"tableName\": \"Images\"\n    },\n    {\n      \"name\": \"Project\",\n      \"tableName\": \"Projects\"\n    }\n  ]\n}\n```\n\n### HEAD /api/Tags\n\nReturns a description of a declared model\n\n```console\n$ curl -i -X HEAD http://localhost:3000/api/Tags\n```\n\nThe result of the request is part of the response headers! The header's name is `Sequelize-Admin`.\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"name\": \"Tag\",\n    \"tableName\": \"Tags\",\n    \"attributes\": {\n      \"title\": \"VARCHAR(255)\",\n      \"id\": {\n        \"type\": \"INTEGER\",\n        \"allowNull\": false,\n        \"primaryKey\": true,\n        \"autoIncrement\": true\n      },\n      \"createdAt\": {\n        \"type\": \"DATETIME\",\n        \"allowNull\": false\n      },\n      \"updatedAt\": {\n        \"type\": \"DATETIME\",\n        \"allowNull\": false\n      },\n      \"ProjectId\": {\n        \"type\": \"INTEGER\"\n      }\n    }\n  }\n}\n```\n\n### GET /api/Tags/1\n\nReturns the data of the Tag with the id 1.\n\n```console\n$ curl http://localhost:3000/api/Tags/1\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"title\": \"foo\",\n    \"id\": 1,\n    \"createdAt\": \"2013-02-09T09:48:14.000Z\",\n    \"updatedAt\": \"2013-02-09T09:48:14.000Z\",\n    \"ProjectId\": 1\n  }\n}\n```\n\n### POST /api/Tags\n\nCreating a new instance of a model\n\n```console\ncurl -d \"title=hallo%20world\" http://localhost:3000/api/Tags\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"title\": \"hallo world\",\n    \"id\": 1,\n    \"createdAt\": \"2013-02-09T09:48:14.000Z\",\n    \"updatedAt\": \"2013-02-09T09:48:14.000Z\"\n  }\n}\n```\n\n### PUT /api/Tags/1\n\nUpdating an already existing instance of a model\n\n```console\ncurl -d \"title=fnord\" -X PUT http://localhost:3000/api/Tags/1\n```\n\nIt returns the updated record\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"title\": \"fnord\",\n    \"id\": 1,\n    \"createdAt\": \"2013-02-14T19:52:04.000Z\",\n    \"updatedAt\": \"2013-02-14T19:53:30.066Z\",\n    \"ProjectId\": 1\n  }\n}\n```\n\n### PATCH /api/Tags/1\n\nUpdating an already existing instance of a model\n\n```console\ncurl -d \"title=fnord\" -X PATCH http://localhost:3000/api/Tags/1\n```\n\nIs processed and returns updated record equivalent to [PUT /api/Tags/1](#put-apitags1).\n\n\n### DELETE /api/Tags/1\n\nDeleting an existing instance of a model\n\n```console\ncurl -i -X DELETE http://localhost:3000/admin/api/Tags/3\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {}\n}\n```\n\n## The API for Associations\n\n### GET /api/Projects/1/Tags\n\nReturns all the instance of 'associated_dao_factory' associated to the instance 1 of 'dao_factory'\n\n```console\ncurl -i -X GET http://localhost:3000/admin/api/Projects/1/Tags\n\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {\n    \"title\": \"foo\",\n    \"id\": 1,\n    \"createdAt\": \"2013-02-09T09:48:14.000Z\",\n    \"updatedAt\": \"2013-02-09T09:48:14.000Z\",\n    \"ProjectId\": 1\n  }\n}\n```\n\n### DELETE /api/Photo/1/Photographer\n\nDeleting an existing association for 1:1 or N:1 association.\n\n```console\ncurl -i -X DELETE http://localhost:3000/admin/api/Photo/1/Photographer\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {}\n}\n```\n\n### DELETE /api/Projects/1/Tags/1\n\nDeleting an existing association between instances\n\n```console\ncurl -i -X DELETE http://localhost:3000/admin/api/Projects/1/Tags/3\n```\n\n```js\n{\n  \"status\": \"success\",\n  \"data\": {}\n}\n```\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsequelize%2Fsequelize-restful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsequelize%2Fsequelize-restful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsequelize%2Fsequelize-restful/lists"}