{"id":13562916,"url":"https://github.com/ndelvalle/generator-api","last_synced_at":"2025-04-05T16:07:16.345Z","repository":{"id":9663065,"uuid":"62930900","full_name":"ndelvalle/generator-api","owner":"ndelvalle","description":"🚀 Yeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express","archived":false,"fork":false,"pushed_at":"2023-02-03T02:28:28.000Z","size":1472,"stargazers_count":250,"open_issues_count":21,"forks_count":49,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-29T15:05:51.706Z","etag":null,"topics":["api","es6","expressjs","mongoose","node","rest-api","yeoman","yeoman-generator"],"latest_commit_sha":null,"homepage":"https://ndelvalle.github.io/generator-api/","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/ndelvalle.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":"2016-07-09T03:49:27.000Z","updated_at":"2024-09-10T10:01:20.000Z","dependencies_parsed_at":"2023-02-18T02:25:30.921Z","dependency_job_id":null,"html_url":"https://github.com/ndelvalle/generator-api","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndelvalle%2Fgenerator-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndelvalle%2Fgenerator-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndelvalle%2Fgenerator-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ndelvalle%2Fgenerator-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ndelvalle","download_url":"https://codeload.github.com/ndelvalle/generator-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361687,"owners_count":20926643,"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":["api","es6","expressjs","mongoose","node","rest-api","yeoman","yeoman-generator"],"created_at":"2024-08-01T13:01:13.363Z","updated_at":"2025-04-05T16:07:16.323Z","avatar_url":"https://github.com/ndelvalle.png","language":"JavaScript","readme":"# generator-api\n\n[![Codeship Status for ndelvalle/generator-api](https://app.codeship.com/projects/2078d9b0-07a0-0136-24ea-22486c3356cd/status?branch=master)](https://app.codeship.com/projects/281027)\n[![dependencies Status](https://david-dm.org/ndelvalle/generator-api/status.svg)](https://david-dm.org/ndelvalle/generator-api)\n[![devDependencies Status](https://david-dm.org/ndelvalle/generator-api/dev-status.svg)](https://david-dm.org/ndelvalle/generator-api?type=dev)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c4ef0a3c22c940469bb69af91a44f386)](https://www.codacy.com/app/ndelvalle/generator-api?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=ndelvalle/generator-api\u0026utm_campaign=badger)\n\n[![NPM](https://nodei.co/npm/generator-api.png?downloads=true)](https://nodei.co/npm/generator-api/)\n\nYeoman generator for creating RESTful NodeJS APIs, using ES6, Mongoose and Express. The fastest way to get your project up and running using an awesome stack.\n\n![generator](http://yeoman.io/static/illustration-home-inverted.91b07808be.png)\n\n\n## Getting started\n\n- Make sure you have [yeoman](https://github.com/yeoman/yo) installed on your machine:\n    `npm install -g yo`\n- Install the generator **globally**: `npm install -g generator-api`\n- Run: `yo api`, or `yo` and choose `Api` option\n\n## Running the generated project\n\nMake sure you have node version `\u003e= 6` because this project uses native supported ES6 features.\n\n### Development\n\n- Run: `mongod` to start the local mongodb in a separated terminal instance (If you don't have mongodb installed locally, visit It's [webpage](https://docs.mongodb.com/manual/installation/) to learn how to install it).\n- Run: `npm run dev` to run the app (By default the app will run at `localhost:8080`, you can change this in the config file).\n\n**Did you choose Docker (:whale:) support?**\n\nYou only need [Docker](https://docs.docker.com/engine/installation/) and [docker-compose](https://docs.docker.com/compose/install/) installed, forget about having node, mongodb or npm.\n\n- Run: `docker-compose up` to run the app. _You might need `sudo` for this one_.\n\n_NOTE_: The Dockerfile uses `node:latest` as its starting point, if you wish to use another version of Node check out the available ones [here](https://hub.docker.com/_/node/).\n\n### Production\n\nYou'll likely be consuming mongodb as a service, so make sure to set the env var pointing at it. Then run `npm start`.\n\n**Using Docker**\n\nBuild the Docker container and run it:\n\n```bash\nsudo docker build -t \u003cimage-name\u003e .\nsudo docker run \\\n  -p \u003chost-port\u003e:8080 \\\n  -d \u003cimage-name\u003e \\\n  -e MONGO_DB_URI=mongodb://\u003cusername\u003e:\u003cpassword\u003e@\u003chost\u003e:\u003cport\u003e \\\n  npm run start\n```\n\n## Architecture\nAssuming we use `user` and `pet` models the generated project will look like this:\n\n```\n├───index.js\n├───routes.js\n├───package.json\n├───config.js\n└───lib/\n|   ├───controller.js\n|   ├───facade.js\n└───model/\n    ├───user/\n    │   └───controller.js\n    |   └───facade.js\n    |   └───router.js\n    |   └───schema.js\n    └───pet/\n        └───controller.js\n        └───facade.js\n        └───router.js\n        └───schema.js\n```\n\n#### Controller:\nHTTP layer, in this instance you can manage express request, response and next. In `lib/controller` are the basic RESTful methods `find`, `findOne`, `findById`, `create`, `update` and `remove`. Because this class is extending from there, you got that solved. You can overwrite extended methods or create custom ones here.\n\n#### Facade:\nThis layer works as a simplified interface of mongoose and as business model layer, in this instance you can manage your business logic.\nHere are some use case examples:\n* Validate collection `x` before creating collection `y`\n* Create collection `x` before creating collection `y`\n\nIn `lib/facade` you have the basic support for RESTful methods. Because this class is extending from there, you got that solved. You can overwrite extended methods or create custom ones here. Also you can support more mongoose functionality like `skip`, `sort` etc.\n\n## Model subgenerator\n\nOnce you have the generated project, if you want to add a new model you can simply run `yo api:model`. This will generate a new folder under `model`, in order to make it work, you just need to import the route into the `routes.js`.\n\nExample:\n\n* Run `yo api:model`, write foo (What ever model name you want)\n* Go to `routes.js` and import the new generated model route `const foo = require('./model/foo/router')`\n* Use the imported route `router.use('/foo', foo)`\n\n## Contributing\nContributors are welcome, please fork and send pull requests! If you find a bug or have any ideas on how to improve this project please submit an issue.\n\n\n## License\n[MIT License](https://github.com/ndelvalle/generator-api/blob/master/LICENSE)\n\n## Style guide\n[![Standard - JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n","funding_links":[],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndelvalle%2Fgenerator-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndelvalle%2Fgenerator-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndelvalle%2Fgenerator-api/lists"}