Quickly creating a CRUD API with Express AutoCRUD

JuanCarlos Chavez
JuanCarlos Chavez
Posted underTech

After setting up my express app with a /routes , /controllers , and /models directories, I enjoyed how everything has it’s place.

That is until I started repeating myself whenever i wanted to introduce a new resource.

I would have to define a model with mongoose, create controllers for creating, reading, updating, and deleting the model. Then I had to create each route (POST, GET, PUT, DELETE) to hit each one of those methods inside of my controller and check do validation logic to ensure some of the properties were present.

I started with about 5-8 models at first, then I got to 15-20 models as continued adding/prototyping new functionality. For each new resource I was

  1. Create a mongoose model representing the resource inside of the ./models directory
  2. Copying and pasting a recent controller in the /controllers directory
  3. Updating which properties to do validation on
  4. Setting up the routes in the ./routes directory
  5. Testing and validating each new route

Finally decided I had to do something about this. Introducing ‘Express AutoCRUD’

Pass in a configuration object (or array of objects) to quickly create a self documenting CRUD api.

I created an NPM package that can easily wrap all those routes, models, and controllers by a simple JSON config.

https://www.npmjs.com/package/express-autocrud

You can check out the open source code base here! :

https://github.com/JuanCarlosC/express-autocrud

This project has gone inactive as of 02/05/2020

Get notified about tech, design, and entrepreneurship posts:

Subscribe to our newsletter to get to know about my latest projects and posts.


More Stories

Youtube, Podcast, & Life Updates – March 2021

The beginning of the quarter of the year is always a hectic time for me. We’re just coming off from holidays, getting back into work, & preparing for tax season. I always tend to feel refreshed and ready to attack the year in Jan & Feb with my list of goals in hand, being filled […]

JuanCarlos Chavez
JuanCarlos Chavez

How To Code a Personal Website STEP by STEP for Beginners! With FREE Hosting 2021 Edition

Have you ever wanted to learn to code but didn’t know where to start? You are in the right place. This blog is to help accompany the video above as a written guide. Who is this guide for? This tutorial is designed for those who are total beginners to web development and coding. Have you […]

JuanCarlos Chavez
JuanCarlos Chavez

Working on my second Youtube Video

I am at the beginning of my content creation journey and I have to admit, it’s asking me a lot deeper questions of myself and who am I more than I thought. Some questions come to mind: What kind of stuff do you want to share with the world? What would you do if you […]

JuanCarlos Chavez
JuanCarlos Chavez

2021 Goals

This is the year that I’ve decided to be more open than ever especially in the digital space. One way of doing this is by sharing the goals I am attempting to accomplish this year. It was tough trying to balance setting achievable goals and ambitious goals. I, as the pragmatic type, try to lean […]

JuanCarlos Chavez
JuanCarlos Chavez

How I created my first video & launched my YouTube Channel

First of all, Happy 2021! I know the craziness still exists but man it feels good that a fresh new number was added to the year ? Why start a YouTube Channel? There are 5 main reasons why I decided to finally hit record & upload: I want to be a producer rather than a […]

JuanCarlos Chavez
JuanCarlos Chavez

Recreating NASA’s UI for their Mission Control Tech

It’s pretty cool that NASA has an open-source javascript project that anyone can contribute to. You can actively write some code with the mission of space exploration & scientific discovery with some HTML, CSS, and JavaScript! This was my first glimpse into NASA’s openMCT program where they are determined to create a universal mission control […]

JuanCarlos Chavez
JuanCarlos Chavez

The Simple Intro Guide to Accounting for Small Businesses

When you create a business the first step is to register your business with your state. Each state has different processes fortunately (or unfortunately) that you could learn to do yourself but it can get clunky and weird. If you have some extra money (around $500) it’s highly recommended that you start your business with […]

JuanCarlos Chavez
JuanCarlos Chavez

How I Coded Up My Own Blog with NextJS and WordPress

If you are reading this post before in 2020 or 2021, odds are the website you are reading is built with the technologies I will be mentioning. I say this since you can inspect the code on this page pretty easily by right clicking any where on the page an hitting “inspect” and be able […]

JuanCarlos Chavez
JuanCarlos Chavez

Creating a project proposal for an agency in Notion

I have been using Notion for all list keeping including clients for the web design agency I am working to build over at omadesign.co My objective was to create a template “Project Proposal” plan for my future clients. I’ve looked at other samples and watched a few explanations on YouTube can came up with my […]

JuanCarlos Chavez
JuanCarlos Chavez