From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext
Unlock this course with a free trial
Join today to access over 25,000 courses taught by industry experts.
Create and run a basic Express server - JavaScript Tutorial
From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext
Create and run a basic Express server
- So now that we have our project all set up with all the NPM packages and stuff that it needs, the next thing we're going to do is set up and run a very simple server. As we go on, we'll add more and more functionality to this server, but it's good to have a place to start. So what we're going to do is create a new folder inside our project and we'll call it source, s-r-c. And this will hold all the actual source code for our server. So inside this folder, let's create another file and we'll call it server.js. And here's where we're actually going to write the code for our server. So setting up an express server is a pretty simple process with a few basic steps. The first thing we're going to do is use ES 6's new import syntax to import express. And that'll look something like this. We'll say import express from express. And now the way that we actually create an express server is simply by saying, let app = express called with two parentheses after it. This might not make a whole…
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Learning objectives1m 34s
-
(Locked)
Learn the basics of writing a Node server3m 52s
-
(Locked)
Create and set up a Node.js project3m 59s
-
(Locked)
Create and run a basic Express server5m 47s
-
(Locked)
Create and test a GET endpoint6m 27s
-
(Locked)
Read a file with the fs package4m 40s
-
(Locked)
Create and test a POST endpoint8m
-
(Locked)
-
-
-