Merced-Express: If Express Met Ruby on Rails

If you’ve ever used Ruby on Rails it provides many awesome benefits with its command-line interface:

I really do enjoy these tools in rails, but I also really enjoy the flexibility and simplicity of Express when paired with a Mongo Database. So I took it upon myself to create an express-based framework that has a rails like feel and level of productivity. Enter, Merced-Express.

The best way to demonstrate is just to guide you in creating a quick project.

Creating a Todo App with Authentication

Generating the Project

Create a new project with the command npx create-merced-express todoapp

Configuring Settings


make sure to use a mongoDB uri for a database you control.

Generating The Todo Model

Run the resource generator with npm run gen resource Todo

Let’s add some properties to our todo model in models/Todo.js

// New Schema
const TodoSchema = new Schema({
subject: String
}, { timestamps: true });

Adding Authentication

Let’s scaffold out the authentication files with the command npm run gen auth

All the authentication files have been created. All we need to do now is wire the auth middleware to the TodoController

// Import Dependencies
import { Router } from "express";
import Todo from "../models/Todo.js";
import auth from "../config/auth.js"
// Create Router
const TodoRouter = Router();
// Router Middleware


Run the app and you should be able to do the following:

Now we can make requests to all our todo routes as long as we have the token in our header in bearer form.

"Authorization":"bearer <token>"

your token should replace the <token>, no angle brackets should be in the header

Now you can make all your CRUD requests…

index => get request to /todo
show => get request to /todo/:id
create => post request to /todo
update => put request to /todo/:id
destroy => delete request to /todo/:id

That’s it!

In a few commands, you have built a full crud API with authentication with fully customizable code. Enjoy! Tell Your Friends!

Alex Merced is a Full Stack Developer, learn more about his work at

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store