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

express-auto-helper

v1.0.3

Published

**Express Auto Helper** is a CLI tool designed to help you quickly generate Express.js controllers and routes. This tool will automatically create a new controller or route file and link it to the main `index.js` files in your project, making it easier to

Downloads

13

Readme

Express Auto Helper

Express Auto Helper is a CLI tool designed to help you quickly generate Express.js controllers and routes. This tool will automatically create a new controller or route file and link it to the main index.js files in your project, making it easier to scale your Express application.

Features

  • Controller Generation: Easily create controllers with pre-defined methods (index, show, create, update, delete).
  • Route Generation: Create routes that are linked to their respective controllers.
  • Automatic Linking: The tool automatically updates the index.js files within the controllers and routes folders, so new controllers and routes are immediately usable.

Installation

Install the package globally,

npm i -g express-auto-helper

Usage

Once the package is installed, you can use the following commands to generate controllers and routes.

1. Creating a new Project

To create a new project, run:

express-auto-helper create-app <new-app>

Example

express-auto-helper create-app new-app

2. Creating a Controller

To create a new controller, run:

express-auto-helper create-controller <controllerName>

This command will create a new file in the controllers folder with the specified name, and it will automatically add an export to the index.js in the controllers folder.

Example

express-auto-helper create-controller userController

This will create a file called userController.js in the controllers folder with the following default methods:

  • index
  • show
  • create
  • update
  • delete

3. Creating a Route

To create a new route, run:

express-auto-helper create-route <routeName>

This command will create a new file in the routes folder with the specified name, and it will automatically import and use the corresponding controller. It also updates the index.js in the routes folder for easy access.

Example

express-auto-helper create-route user

This will create a file called user.js in the routes folder with pre-configured routes for:

  • GET /
  • GET /:id
  • POST /
  • PUT /:id
  • DELETE /:id

4. Linking Routes and Controllers in the Main index.js

The tool automatically updates the main index.js file to link all routes. To set up the main file manually, you can include the following code in index.js:

const express = require('express');
const app = express();
const routes = require('./routes');

app.use(express.json());

// Link all routes
Object.keys(routes).forEach((routeName) => {
  app.use('/' + routeName, routes[routeName]);
});

app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});

File Structure

The CLI tool will create a folder structure like this:

my-express-app/
├── controllers/
│   ├── index.js
│   └── userController.js
├── routes/
│   ├── index.js
│   └── user.js
└── index.js

License

No lisence **

Contributing

Contributions are welcome! If you have any feature requests or find any bugs, feel free to submit an issue or create a pull request.


Enjoy building with Express Auto Helper!