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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tegain/vue-cli-plugin-mevn

v0.1.3

Published

Add MEVN REST API boilerplate to your Vue-CLI project

Downloads

215

Readme

Vue-CLI MEVN Plugin

For Vue-CLI v3.x only

Easily Add MEVN (MongoDB, Express, Vue, Node), ES6-ready stack to your Vue-CLI project.

Installation

Generate a project using vue-cli 3.0 (or use your current Vue-CLI project)

vue create my-app

cd my-app

Add the plugin to your project

vue add @tegain/vue-cli-plugin-mevn

You'll then have to configure your API and database access with a few questions:

# API Port (default: 5000). 
# Access the API at http://localhost:<PORT>
- Enter API PORT

# Database connection URL (local or remote). 
# Must be a valid `mongodb://` URL
- Enter Mongo database url 

# API prefix (default: none). Add a global prefix to your API routes. 
# Example: /api/v1 -> Access the API at http://localhost:<PORT>/api/v1
- Enter API prefix

Now you just have to install API dependencies, by running the following NPM command from your Vue project root:

npm run api:install

Answer the few questions and you're done!

What it does

This plugin will add an api/ folder at the root of your project, containing a boilerplate to start using Express and MongoDB.

Features:

  • Server: Express - docs
  • Database: MongoDB (with Mongoose - docs)
  • Logging: Morgan - docs
  • Environment-specific variables
  • ESLint
  • Modularized architecture
  • Custom, preformatted Exceptions

Folders structure

api
 |-src
   |-config           # Global variables & environments configuration
   |-database         # Database connection
   |-modules          # Actual API modules
   |-services         # Application services (LoggerService, etc.)
   |-utils            # Util methods
   |---exceptions     # Custom exceptions
 |-.babelrc 
 |-.env.development   # Dev-specific variables
 |-.env.production    # Production-specific variables
 |-.eslintrc.js
 |-.gitignore
 |-package.json
src (your Vue project)
 |-...

Start the API

You can start the API by running the following NPM command:

# Production build
npm run start

# Development build with Nodemon watching for your changes
npm run start:dev

Adding this plugin will also add 2 NPM commands to your Vue project's package.json, so you can start the API directly from your project root:

  • api:start
  • api:start:dev

Modules

Architecture

The API project is built so a module folder contains every files needed to this module:

|-moduleName
   |-models                     # Module Mongoose schemas/models
   |-moduleName.module.js       # Module entrypoint, defining the routes / HTTP methods association
   |-moduleName.controller.js   # Module controller, dealing with the API logic
   |-moduleName.service.js      # Module service, handling communication with the database

(How-to) Create a module

In the /api/modules folder, create a new folder with the name of your module. We'll create a Users module, so the folders architecture will look like this:

|-api
  |-src
    |-modules
      |-users
         |-models
           |-user.model.js
         |-users.module.js
         |-users.controller.js
         |-users.service.js
      |- ... other modules

Creating the module entrypoint

// users.module.js
import express from 'express';
import { UsersController } from './users.controller';

export const UsersModule = express.Router();

UsersModule.get('/', UsersController.findAll);
UsersModule.post('/', UsersController.addUser);

Creating the module controller

// users.controller.js
import { UsersService } from './users.service';

export class UsersController {
	// Return all users
	static async findAll (req, res) {
		const users = await UsersService.findAll();
		return res.status(200).json(users);
	}
	
	// Add a new user
	static async addUser (req, res) {
		const user = await UsersService.addOne(req.body);
		return res.status(201).json(user);
	}
}

Creating the module service (aka actually dealing with the database)

// users.service.js
import { UserModel } from './models/user.model';
import { NotFoundException } from "../../utils/exceptions";

export class UsersService {
	static async findAll () {
		return await ExampleModel.find().exec();
	}

	static async findById (id) {
		const document = await ExampleModel.findById(id);
		if (!document) throw new NotFoundException();
		return document;
	}

	static async addOne (data) {
		return await ExampleModel.create(data);
	}
}

(How-to) Add a module to the API

Then, in app.js, import and initialize your module inside the initializeModules() class method:

// /api/app.js
import { UsersModule } from './modules/users/users.module';

class AppFactory {
  // ...
	
  initializeModules () {
    this.addModule(
    	'users',     // Module route mapping
    	UsersModule   // Module entrypoint
    );
    
    // ... Other modules
  }
}

Using the addModule instance method, you can map an API base route with your module.

addModule takes two parameters:

  • your module name, used as a route mapping
  • your module entrypoint

For example, for the UsersModule above, your module will respond to http://localhost:<PORT><PREFIX>/users routes.

To view a functional example, see: