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

node-boiler

v1.1.9

Published

Node boiler is a library that automatically writes boiler plate code which otherwise does not come out of the box with node.js. This tool comes in handy while make REST APIs.

Downloads

26

Readme

npm version Build Status MIT license PRs Welcome

:computer: Generate all your boiler plate code for writing REST APIs with just one command.

Demo

Installation

This Node.js module is available through npm registry

Install the module globally by running the following command

$ npm i -g node-boiler

Note: Not installing it gloabally may cause it to malfunction. We're working on the fix.

Usage

  1. Create a boil.yml file in your project directory specifying your configuration. Scroll below to see the semantic rules for writing your own boil.yml

example boil.yml

models:
  - 'users'
  - 'admins'
  - 'players'

controllers:
  authController:
    - 'login'
    - 'signUp'

  playerController:
    - 'pass'
    - 'shoot'

views:
  - 'home'
  - 'profile' 

routes:
  admin-routes:
    post:
      - '/delete'
      - '/another-route'
    get:
      - '/get-here'
      - '/lol'
  player-routes:
    get:
      - '/shoot'
      - '/kick'
  1. Generate directories and files as per your configuration
$ cd yourprojectdirectory
$ nodeboil
  1. Your root project directory will then look like
 --node_modules
   |--your modules
 --models
   |--users.js
   |--admins.js
   |--players.js
 --views
   |--home.html
   |--profile.html
 --controllers
   |--authController.js
   |--playerController.js
 --routes
   |--admin-routes.js
   |--player-routes.js
 --boil.yml
 --package.json
 -- <entry file>.js

Note: The generated files will come with all basic boiler plate code. Try it out!

Writing boil.yml file

This file must be present in the root directory of your project. The syntax for writing boil.yml is as follows

models:
  - '<Model Name 1>'
  - '<Model Name 2>'
  ...
routes
  - <name of route file 1>
    - <route method>
      - '<URL endpoint 1>'
      - '<URL endpoint 2>'
      ...
     ...
  - <name of route file 2>
    - <route method>
      - '<URL endpoint 1>'
      - '<URL endpoint 2>'
      ...
     ...
  ...
  
controllers:
  - <Name of controller 1>
    - '<Function name 1>'
    - '<Function name 2>'
    ...
  - <Name of controller 2>
    '<Function name 1>'
    '<Function name 2>'
    ...
  ...

views:
  - '<Name of html file 1>'
  - '<Name od html file 2>'
  ...

Once done, execute the command nodeboil in the root of the project directory.

Note: Renaming the file to anything other than boil.yml will not work

Features

  • Generates all your mongoose models

Example of a generated model file (admin.js) under the generated directory /models

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
        
const adminsSchema = new Schema({}); //Write your schema here
        
const admins = mongoose.model('admins', adminsSchema); 
     
module.exports = admins;
  • Generates routes as per your configuration

Example of a generates routes file (admin-routes.js) under the generated directory /routes

const router = require('express').Router;

router.post('/delete', (req, res) => {}); // Add your route logic here
router.post('/another-route', (req, res) => {}); // Add your route logic here
router.get('/get-here', (req, res) => {}); // Add your route logic here
router.get('/lol', (req, res) => {}); // Add your route logic here

module.exports = router;
  • Generates basic html templates under the generated directory /views
  • Generates controllers for your REST APIs as per your configuration

Example of a generated controller file (authController.js) under the generated directory /controllers

module.exports = {
login: function(){},// Add function logic here
signUp: function(){},// Add function logic here
}

Tests

To run the test suite, execute the following command :

$ npm install
$ npm run test

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

We are always looking forward to new ideas and meaningful contributions.

License

MIT