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

generator-restgoose

v0.5.95

Published

Modern, Lightweight, and Powerfull Rest API Code generator. Out-Of-Box NodeJS REST API Server generator built on top of Mongoose, Express, Cors, Passport, JWT and many more.

Downloads

183

Readme

generator-restgoose Build Status npm version Join the chat at https://gitter.im/generator-restgoose/Lobby

Mongoose RESTful API generator for your NodeJS Express App v0.5.95

A custom-built Mongoose generator for Yeoman. The base project has been forked from afj176/generator-mongoose and has been updated with many new features, tests and tweaks to get you full fledged out-of-the-box NodeJS Express API Application up and running, Route vs Model Segregation and much more.

NPM

**Minimum Node Version : 9.x
Minimum NPM Version : 5.x
Minimum Yo Version : 2.x **

Installation

First, install Yeoman and generator-restgoose using npm (we assume you have pre-installed node.js).

npm install -g yo
npm install -g generator-restgoose

Usage

Prepare Working Directory

$ mkdir server && cd server

Then generate your new project:

$ yo restgoose

And generate schema:

$ yo restgoose:schema "category|name:String"
$ yo restgoose:schema "item|name:String, price:Number, category:String>category"

the category:String>category dneotes that category field will be created with string type, which referes to previously created schema 'category'.

Generate Authentication

$ yo restgoose:auth

do read the generated doc for auth before you start using it.

Generate Delete a generated Schema

$ yo restgoose:deleteSchema "item" --force

Run the server

$ npm start

Whats New in v0.5.x?

  • Major Feature Release
  • Docker Support
  • Complete re-write of architecture from scratch
  • yo v2 complied
  • Fully npm Audited generator & fascilitator code
  • npm audit fixed!
  • SDK Codes for Unity and Angular
  • Advanced Searching out of the box
  • ...More

Quick Links

If you would like to contribute, please refer to guidelines and a list of open tasks.

For more information, please refer to the Wiki page and FAQ

Troubleshooting

Try updating your yo to latest version. open a new issue in github for any problems you might face.

Overview

  • Scaffolds out-of-the-box REST API Server
  • Full blow n ready to use Authentication and Authorization (Passport + JWT + Redis)
  • Generates All Ready to run files - Model ( Mongoose) - Api Route (endpoint) - Api Object (Business Layer, crud logic) - Documentation (API reffernce) - Test File
  • Generates ready-to-rock README file with License(MIT), etc.
  • Runtime Configurable Email System
  • Highly Scalable System Configuration based on environment
  • Conforms to jSend Specs for API JSON Response
  • Modular and based on Seperation of Concern
  • Fast and readible code generation
  • Email Templates
  • Full Blown JWT REST Authentication
  • ... much more

Table of contents

Getting Started

What is Yeoman?

Trick question. It's not a thing. It's this guy:

Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.

Not every new computer comes with a Yeoman pre-installed. He lives in the npm package repository. You only have to ask for him once, then he packs up and moves into your hard drive. Make sure you clean up, he likes new and shiny things.

$ npm install -g yo

Generator Restgoose

While running through a leafy mongodb field he picked up mongoose.
Generator-Restgoose scaffolds all API Routes, API Objects ( Bussiness Logic), Schema Models, Test Cases, and even Documentation for you with full CRUD functionality.

To install generator-restgoose from npm, run:

$ npm install -g generator-restgoose

Finally, initiate the generator:

$ yo restgoose

It should output a file structure similiar to:

.bowerrc
.editorconfig
.jshintrc
api/
apiObjects/
config/
... db.js
... lib.js
docs/
public/
models/
routes/
... index.js
sdk/
test/
views/
bower.json
Gruntfile.js
package.json
Readme.md
  • models - contains Mongoose Schema of an entity ( Data Layer)
  • apiObjects - Contains business logic & model access for each entity ( Business Layer )
  • api - Contains routes of each entity ( Presentation Layer / Controller )
  • test - contains unit test cases for each entity
  • docs - contains Detailed markdown formatted documentation of each Schema generated through the sub-generator.
  • sdk - contains rest api controllers for Unity C# and Angular 5 code

Put All Configurations in concerned environment in ./config. All of them inherit from global. Don't forget to checkout the require('./config').util module which contains many useful stuff (Json Validator, image to Base64 Converter, etc). Use the Library as var l = require('../config').util; ( which generates with every sub schema).

Try to use l.p('Print something'); to log something. This will log to debug.log file.

Logging Two log files are served : debug.log and access.log.

All responses are valid jSend spec conformed JSON format.

Prepare for Development Server

npm start

Prepare for Test Server

npm test

Run the app

Development mode

$ npm start

Sub Generators

Schema

Creates all required Model, Controllers, test cases, routes and documentations for a particular Schema. Run the sub generator for schemas:

$ yo restgoose:schema "article|title:String,excerpt:String,content:String,published:Boolean,created:Date"

output:

You're creating a schema for article
With the fields: title,excerpt,content,published,created
create routes/article.js
create models/article.js
starting request to schematic for test mock data...
create test/test-article.js
create doc/article.md

DeleteSchema

Deletes all files (Model, APi Route, API Object, Doc, Test) for a particular schema. Run the sub generator for deleteschema:

$ yo restgoose:deleteSchema "article" --force

N.B. You need to use --force else y=Yeoman will continue asking you to overwrite each file.
output:

You're deleting all files for schema: article

force api/article.js
force apiObjects/article.js
force models/article.js
force docs/article.md
force test/test-article.js

Auth

Enabled Passport + Redis + JWT based Authentication and Authorization for your RESR API server.

$ yo restgoose:auth "auth"

N.B. Run this before creating user model and auth controllers or else, they will be overwritten.
output:

Instantiating Authentication ...


   create api/auth.js
   create apiObjects/auth.js
   create models/user.js
   create middlewares/passport.js
   create docs/auth.md
   create routes/sampleauth.js

You should checkout the docs/auth.md after issuing this command for complete reference.

Getting To Know Yeoman

Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.

If you'd like to get to know Yeoman better and meet some of his friends, Grunt and Bower, check out the complete Getting Started Guide.

Command List

  • mkdir newAPi && cd $_ - Create new Server Directory and cd into it.
  • yo restgoose - initiate a project
  • yo restgoose:auth - Install JWT and redis ready auth system
  • Uncomment app.js sections for auth and redis
  • yo restgoose:schema "<schema>|field:DataType" - Create all routers, models, test and docs for a schema
  • yo restgoose:deleteschema "<Schema>" - Delete all related generated files for a schema
  • grunt - start server with watch enabled
  • npm test - Start Testing generated schemas

Architecture

WIP

ChangeLog

Detailed Changelog

Bucket List

Create Test for auth and delete sub-generators

  • Write Testcase checking auth sub-gen
  • API Dynamic on-demand Doc Generator
  • Conform to REST API Standards
  • Socket.IO Generator (wohooo)
  • Docker Scripts
  • AutoStart Script using PM2 ( 1 click deploy)
  • Modulraize Architecture as Plug and play and SoC - will take huge time
  • ~~Complete ReadME file for the generated api project~~
  • ~~Pre-defined generated docs for the generated API endpoints~~
  • ~~Complete README file for generator-restgoose project (this one)~~
  • ~~Write Reasons, Troubleshooting and migration for v0.1.5 to 0.1.6 in a wiki/blog~~ - NA
  • ~~Seperate Nevironment Based Configurations~~
  • ~~API Versioning System~~
  • ~~out-of-the-box passportJS authentication with JWT~~ \m/-

Generator Restgoose Core Team

License

MIT
Copyright 2016 - 2018 Abhishek Deb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

:warning: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

NPM

NPM