DEV Community

Cover image for Let's Build Express Server. Beginners Guide
Shreyansh sheth
Shreyansh sheth

Posted on

Let's Build Express Server. Beginners Guide

What Is Express Js?

Express Js Is Web Framework For Node.js

Where To Use Express Js

  • Most Popular Use Of Express Js In the Current Time Is To Create Web Apis.
  • Also Some People Are Using To Create Full-stack Web App With using Pug, Ejs, Or Basic HTML

here we are going to create a simple API to understand concepts of express

Getting Started

Requirements

  • You need Node.js Installed In Your System. You can download node.js from Node.js

  • Open New Directory And Write This command to initialize a new project.
    npm init -y

-Now install express as dependencies for your project
npm install express

Create basic hello world API

  1. Create index.js file and import express js & initialize the app

Express Import & init app

  1. Create an endpoint

in simple term endpoint is a path where you are getting expected data
/users return all users
/products returns all products

endpoint creatiion
here we have created endpoint / where we are sending hello world as a response.

3 Open a port for connections

Open Port

  1. Run application > write node index.js to start the application

shell

  1. open localhost:3000 on browser browser image

hooray you made it 🥳

what now

now try to render Html. try to create forms & process data using any database.

find material online and create your own express apps.

Top comments (0)