{"id":20251282,"url":"https://github.com/paranoiasystem/fastify-autocrud","last_synced_at":"2025-04-10T23:02:18.699Z","repository":{"id":57233287,"uuid":"203168712","full_name":"paranoiasystem/fastify-autocrud","owner":"paranoiasystem","description":"Plugin for autogenerate CRUD routes as fast as possible","archived":false,"fork":false,"pushed_at":"2024-01-22T02:09:55.000Z","size":103,"stargazers_count":14,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T23:25:46.150Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paranoiasystem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-19T12:30:54.000Z","updated_at":"2024-10-01T20:25:07.000Z","dependencies_parsed_at":"2022-08-31T18:33:51.489Z","dependency_job_id":null,"html_url":"https://github.com/paranoiasystem/fastify-autocrud","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paranoiasystem%2Ffastify-autocrud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paranoiasystem%2Ffastify-autocrud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paranoiasystem%2Ffastify-autocrud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paranoiasystem%2Ffastify-autocrud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paranoiasystem","download_url":"https://codeload.github.com/paranoiasystem/fastify-autocrud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224601041,"owners_count":17338455,"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-14T10:02:49.434Z","updated_at":"2024-11-14T10:02:50.202Z","avatar_url":"https://github.com/paranoiasystem.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-autocrud\n\n\u003cdiv align=\"center\"\u003e\n\n[![build status](https://travis-ci.org/paranoiasystem/fastify-autocrud.svg?branch=master)](https://travis-ci.org/paranoiasystem/fastify-autocrud)\n[![issues](https://img.shields.io/github/issues/paranoiasystem/fastify-autocrud)](https://github.com/paranoiasystem/fastify-autocrud/issues)\n[![Coverage Status](https://coveralls.io/repos/github/paranoiasystem/fastify-autocrud/badge.svg?branch=master)](https://coveralls.io/github/paranoiasystem/fastify-autocrud?branch=master)\n[![license](https://img.shields.io/github/license/paranoiasystem/fastify-autocrud)](./LICENSE)\n![version](https://img.shields.io/npm/v/fastify-autocrud)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n[![Beerpay](https://img.shields.io/beerpay/paranoiasystem/fastify-autocrud)](https://beerpay.io/paranoiasystem/fastify-autocrud)\n\n\u003c/div\u003e\n\nPlugin for autogenerate CRUD routes as fast as possible. \n\n## Install \n\n```\nnpm i fastify-autocrud --save\n```\n\n## Usage\n\n```js\nfastify.register(require('fastify-autocrud'), {\n    prefix: '/api/products',\n    Collection: require('../models/Product')\n})\n```\n\n**_Product.js_**\n```js\nconst mongoose = require('mongoose')\n\nconst Product = new mongoose.Schema({\n  name: String,\n  description: String,\n  image: String,\n  cost: Number,\n  price: Number,\n  qty: Number\n}, {\n  timestamps: true\n})\n\nmodule.exports = mongoose.model('Product', Product)\n```\n\nIf you want add custom routes\n\n```js\nconst customController = require('customController')\n\nfastify.register(require('fastify-autocrud'), {\n    prefix: '/api/products',\n    Collection: require('../models/Product'),\n    additionalRoute: customController\n})\n```\n\n**_customController.js_**\n```js\nconst boom = require('boom')\n\nconst customRoute = {\n    method: 'GET',\n    url: '/custom',\n    handler: async function (req, reply) {\n        try {\n            reply.type('application/json').code(200).send({ \"customroute\": \"ok\" })\n        } catch (err) {\n            throw boom.boomify(err)\n        }\n    }\n}\n\nmodule.exports = [customRoute]\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparanoiasystem%2Ffastify-autocrud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparanoiasystem%2Ffastify-autocrud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparanoiasystem%2Ffastify-autocrud/lists"}