1
00:00:00,000 --> 00:00:04,960
[MUSIC]

2
00:00:04,960 --> 00:00:11,340
In the previous module, we have seen
how we can make use of Express and

3
00:00:11,340 --> 00:00:17,170
Express router to build up a web
server to sum up Rest API.

4
00:00:17,170 --> 00:00:23,980
We constructed the entire web server by
hand and organized the files by ourselves.

5
00:00:23,980 --> 00:00:28,170
Wouldn't it be nice if we had a tool
that can automatically generate

6
00:00:28,170 --> 00:00:31,980
a standard structure for
our express application.

7
00:00:33,040 --> 00:00:37,870
Just like we had for angular or ionic or

8
00:00:37,870 --> 00:00:42,000
native script in the previous courses,
some kind of command line interface that

9
00:00:42,000 --> 00:00:47,160
enables us to automatically scaffold
out a start up application and

10
00:00:47,160 --> 00:00:51,370
then you can go in and
modify the application to suit our needs.

11
00:00:51,370 --> 00:00:56,330
So that is where Express Generator
comes to our aid.

12
00:00:56,330 --> 00:01:00,970
Express Generator is a tool that we will
install a command line interface that

13
00:01:00,970 --> 00:01:04,700
we will install as a global NPM module and

14
00:01:04,700 --> 00:01:08,845
it enables us to quickly scaffold
out an Express application.

15
00:01:08,845 --> 00:01:11,010
Let's look at some of the details next.

16
00:01:12,890 --> 00:01:15,800
So as I said,
what exactly is Express Generator?

17
00:01:15,800 --> 00:01:22,140
Express Generator is a quick scaffolding
tool that will help us to quickly build up

18
00:01:22,140 --> 00:01:28,375
the structure for an Express application
with some starting code already built and

19
00:01:28,375 --> 00:01:33,925
some standard middleware already
included into the application.

20
00:01:33,925 --> 00:01:38,110
And so all that we need to do is
install the Express Generator.

21
00:01:38,110 --> 00:01:42,040
Command line interface as
a global NPM module, and

22
00:01:42,040 --> 00:01:46,760
then use that to scaffold
out our Express application.

23
00:01:46,760 --> 00:01:49,200
So how does Express Generator work?

24
00:01:49,200 --> 00:01:53,700
With Express Generator, once you have
installed the Global API module.

25
00:01:53,700 --> 00:01:56,470
You just type Express, space, and

26
00:01:56,470 --> 00:02:00,430
the name of your Express
application that you want to start.

27
00:02:00,430 --> 00:02:02,200
And this will generate a folder

28
00:02:03,290 --> 00:02:06,740
with the name of the application
that you have typed in.

29
00:02:06,740 --> 00:02:12,130
There are various options available for
you to generate your Express application.

30
00:02:12,130 --> 00:02:19,620
It can use different kinds of view
generators like jade, EJS, and so on.

31
00:02:19,620 --> 00:02:23,180
If you're not familiar with them, don't
worry about that too much for the moment.

32
00:02:24,480 --> 00:02:32,020
In this course, we will be using Express
purely as a server that supports REST API.

33
00:02:32,020 --> 00:02:37,260
The client side implementation, we are
already doing that using either angular

34
00:02:37,260 --> 00:02:41,070
Ionic or
native script in this specialization.

35
00:02:42,160 --> 00:02:47,100
And once you scaffold out your
Express application, you just

36
00:02:47,100 --> 00:02:51,149
move into the replication and do an NPM
install to install all the preconfigured

37
00:02:52,170 --> 00:02:57,440
modules that are already included in
your default Express application.

38
00:02:57,440 --> 00:03:00,550
And some of the middleware that,
by default,

39
00:03:00,550 --> 00:03:03,050
will be included into your application.

40
00:03:03,050 --> 00:03:06,520
Once that is done,
then it is just a matter of going in and

41
00:03:06,520 --> 00:03:12,170
modifying that generated
templates to suit your needs.

42
00:03:12,170 --> 00:03:15,880
So what is the typical Express Generated
application look like?

43
00:03:15,880 --> 00:03:18,608
So this would be
the directory structure or

44
00:03:18,608 --> 00:03:22,990
the folder structure generated
by Express Generator.

45
00:03:22,990 --> 00:03:27,312
So you have an app.js file which is
the starting point of your Express

46
00:03:27,312 --> 00:03:30,292
application and
then you have package.json,

47
00:03:30,292 --> 00:03:35,001
which obviously contains the details
because this is a node application.

48
00:03:35,001 --> 00:03:37,948
So this contains all the details
of the dependencies and so

49
00:03:37,948 --> 00:03:39,650
on that will be installed.

50
00:03:39,650 --> 00:03:44,340
Then you have public folder,
where you put your static resources.

51
00:03:45,720 --> 00:03:48,310
Then you have the routes folder,

52
00:03:48,310 --> 00:03:52,790
where you have the various application
routes the REST API adopts.

53
00:03:52,790 --> 00:03:57,340
Now if you recall in the Express
application that we generated earlier,

54
00:03:57,340 --> 00:04:00,230
I explicitly created the routes folder and

55
00:04:00,230 --> 00:04:06,230
put all the Express router
files into that folder.

56
00:04:06,230 --> 00:04:13,030
The reason is simply to keep match with
what Express Generator actually generates.

57
00:04:13,030 --> 00:04:15,990
When it scaffolds out an application.

58
00:04:15,990 --> 00:04:21,680
And then the views is where you have the
template engine for generating standard

59
00:04:21,680 --> 00:04:27,940
web templates, HTML templates,
if you are interested in using them.

60
00:04:27,940 --> 00:04:32,610
In this course, we will be using the views
for our Express application in NAV.

61
00:04:32,610 --> 00:04:35,930
With this quick understanding
of Express Generator,

62
00:04:35,930 --> 00:04:40,720
let's now install
Express Generator in our computer.

63
00:04:40,720 --> 00:04:45,605
And then use it to scaffold
out where several application

64
00:04:45,605 --> 00:04:49,787
that we will develop over
the rest of the course.

65
00:04:49,787 --> 00:04:53,059
[MUSIC]