Generate API In Less than 10 minutes

node js Oct 05, 2019

Yes, You Can Create Rest API Based on mongo and express (node) in less then 10 minutes.Let me show how to do that,

First Let's Visit Smartcodehub.com

Now Click on the upper right corner button Give it a show , You will be redirected to login page, if you have account then login else register yourself there using register button.

After Login, you redirected to home page where you can see the download dropdown where you have to download the stater file,

After downloading the file extract it to place where you want to make project and then open the project in VS Code.

Now you have to run

npm i

and change the database name at line no: 9

const DBNAME = 'sample'; //change it to your db name

Now, get back to website and create Modal Under Entities Dropdown

Give the name to the table, add Fields to it by clicking on + button

You Can also use extra properties like Min Length , Unique , Required , Max Length And Much More by Clicking Extra Properties Button.

After Adding fields and setting up the name to table you can click save button

As You Click the button you will be able to see download button near save button then click on download button.

As you click on download an zip file will be downloaded extract it.You will see 4 file

1) tablename.controller.js  2) tablename.route.js 3) tablename.schema.js

copy the file one by one and paste them accordingly in vscode folder.

Now open the instruction.txt file and do the following changes in app.js

/* Paste the following line available in instruction.txt file */

const  usertableRouter = require("./routes/usertable.route");
 
 app.use("/api/usertable", usertableRouter);

That's it you api is made to test api run the cmd in vs code terminal

node app

and check it in postman.

The video tutorial is here ,

And Lets take it a step ahead and in Next article we will see how we can create an API with image upload functionality with this tool Stay Connected

Neeraj Dana

Experienced Software Engineer with a demonstrated history of working in the information technology and services industry. Skilled in Angular, React, React-Native, Vue js, Machine Learning