Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Getting Started with Express.js to Build a JSON API in Node
Rating: 4.4 out of 5(70 ratings)
3,588 students

Getting Started with Express.js to Build a JSON API in Node

Implement basic web server operations on a Bookstore sample application
Created byRenan Martins
Last updated 3/2023
English
English [Auto],

What you'll learn

  • Learn the first steps to building a web server with the minimalistic Nodejs framework Express.
  • How to build a simple JSON RESTful API using the Express framework.
  • Implement basic Create, Read, Update, Delete (CRUD) actions on the API.
  • Debug the API endpoints with HTTP request software Postman.

Course content

1 section12 lectures1h 33m total length
  • Introduction (Bookstore)3:44

    Learn to use the express framework to build a JSON API for a bookstore, implementing create, read, update, and delete operations with hard coded data.

  • Generating the Project with NPM3:48

    Generate your Node.js project by initializing npm, creating a directory, and installing express, then set up app.js to serve a JSON API.

  • Setting Up and Running the Express Server5:14

    Explore how to set up an express server by creating app.js, requiring express, creating an app, defining port 3000, and starting the server with app.listen and console log.

  • Defining our First GET Route in Express4:53

    Define your first get route in express using app.get('/', (req, res) => res.send('Welcome to Express')), then test at http://localhost:3000/ and restart the server with node app.js.

  • Using Postman to Test the API6:11

    Learn to test Express APIs with Postman, send requests to localhost:3000, view JSON responses and headers, and verify 200 status while restarting the server with node app.js.

  • Writing the Route to Get All Books5:43

    Build a get /books endpoint in Express with a hardcoded fake database and a book module exposing findAll, returning an array of id and title with a 200 response.

  • Writing the GET Route to Get a Specific Book By Id13:43

    Learn to build a get route /books/:bookId in Express, parse the id, find the book with an array search, and return 404 with a message using nodemon for development.

  • Parsing Incoming Request Body in Express using Middleware9:30

    Parse JSON request bodies in Express using middleware. Create a new book with an auto-incremented id at post /books and return the created object.

  • Defining the POST Route to Create a Book8:09

    Define a post route to create a new book in an Express.js JSON API, updating and returning the new book with an incremented id while parsing req.body.

  • Defining the PUT Route to Update a Book13:17

    Define a put route to update a book by id using req.params and req.body in a fake in-memory database, returning 200 with the updated book or 404 if not found.

  • Defining the DELETE Route to Destroy a Book12:34

    Define the delete route for /books/:bookId in Express.js, parse the id, verify the book exists, destroy it, and return 204 no content on success, or 404 or 500 as needed.

  • End of the Express Course Review6:14

    Learn to build a restful json api with express using a bookstore example, covering get, post, put, delete, and req.body via express.json.

Requirements

  • A basic knowledge of Nodejs / JavaScript is required.
  • Some exposure to fundamental database principles is highly advised.

Description

Learn the first steps to building a web server with the minimalistic Node.js framework Express.js.

Step into the basics of setting up a bookstore catalog web service, writing your code in the Node.js (Server-side JavaScript) language and leveraging the framework Express. The course demonstrates how to create a simple RESTful API that serves data in the JSON format.

This course is intended for people who have never touched the framework and are looking for a brief introduction. Some basic knowledge of Node.js / JavaScript is required. Some exposure to fundamental database principles for data storage is highly advised.

NPM is used to generate the project and manage the package dependencies.

The course provides an quick overview of the Express.js framework and gets you started with building a JSON RESTful API with the four basic data operations of CREATE, READ, UPDATE, and DELETE ("CRUD"). To focus on the framework constructs, database configuration and maintenance are omitted from this course; a specific object-relational mapping (ORM) solution is not used nor any other third-party libraries other than Express itself.

The Express.js JSON API endpoints are tested using HTTP requests made by the program Postman, a good choice of software to conveniently debug the routes.

The course is a good quick start if you are looking to get started building APIs in the Node.js language. You can use the basic knowledge from the course to go on to build your own web services. You are welcome to iterate upon the knowledge you obtain from it.

Who this course is for:

  • This course is intended for people who have never touched the Expressjs framework.
  • Those who want to get started building JSON APIs in Nodejs (JavaScript) language.