5. Serverside JS Scripting with Node.js Flashcards

1
Q

Powerful runtime environment for executing JavaScript code outside of a web browser and it brings JavaScript laguage to the server-side - enabling developers to build scalable, high performance and event-driven applications.

A

Node.js

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Eliminates the need for context switching and enables code reuse between the front-end and back-end resulting in improved productivity and reduced development time.

A

allows developers to use JS both on the client-side and server-side providing a unified language and ecosystem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Node.js has a vast and active ecosystem of modules and libraries available through the

A

Node Package Manager (npm)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

NodeJs is particularly well-suited for building

A

web apps
APIs
real-time apps requiring instant data updates
bidirectional communications like chat apps
multiplayer games
streaming applications like audio or video processing
real-time analytics
microservices
scalable APIs
single-page apps
Internet of Things deployments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Among other things Node.js is a

A

web server framework

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

function when called with either read and serve our index.html
generate a 200 success code
or if there is a problem
generate a 500 error code

A

server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

listening port for app and can be any value between 1 and

A

65535

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

calls the server function and modifes port number and writes entry to console.log

A

listen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

used within file system to initialize a new Jode.js project and create a package.json

A

npm init command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

File that serves as the manifest for the project and contains metadata and configuration information about the project, its dependencies, scripts and other details

A

package.json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

to add dependencies you can do it manually or use

A

npm install <package-name></package-name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Automatically generated by npm when you install dependencies for your project and serves as a lockfile that ensures deterministic and reproducible builds of your project across different environments.

A

package-lock.json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The package-lock.json file should be included in version control systems so that other developers or deployment environments can reproduce the exact dependency tree and versions used in the project

A

version control

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

directory created by npm as a storage location for all the packages and modules our project relies on and it is where you install packages using npm install, the downloaded packages are placed here.

A

node_modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

creates hierarchical structure in the node_modules directory

A

reflects dependency tree of your project.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Lightweight and flexible web framework for Node.js for simplifying the development of web applications and APIs and allows developers to easily handle
routing
middleware
HTTP request/response handling

widely used for building scalable and efficient web applications offering a balance between simplicity and powerful functionality for server-side development

A

Express.js

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

File that serves as templates for generating dynamic HTML content and is a popular templating engine that allows you to embed JavaScript code within HTML markeup and each file is a “view” that defines the structure and layout of the rendered web pages.

separate the presentation logic from the application logic

A

EJS - Embedded JavaScript

18
Q

Begins by loading al necessary modules, including Express itself, csv-parser for reading our CSV dat and fs to allow our app to work with the local filesystem

A

app.js

19
Q

Module is middleware designed to handle different types of request data
JSON payloads
URL-encoded data

provides parsing functionality for these types of data and exposes them as properties of the req.body object.

A

body-parser module

20
Q

Method sets EJS as templating engine we will be using and it points to the views/ directory as the location of our tempates files

A

app.set

21
Q

Method defines the encoding bodyParser will use .

A

app .use

22
Q

Method declares a variable that will be used to hold our CSV data

A

.let

23
Q

Method begins by defining the route to be used for requests and responses

A

app.get

24
Q

Tells us that we should look in the same local root directory where the app.js file lives

A

/ forward slash

25
Q

Value here specifies that we want the options column from our data to act as the index column

A

row.option

26
Q

Manages form submission and sends requests from the form page so that the page generated by the result template can be properly managed at the end

A

app.post

27
Q

starts a loop using the forEach method to iterate over each element in the data array.

A

.<% data.forEach((item) => { %>:

28
Q

generates an <option> element for each item in the data array and the value attribute of the option is set to the value of the item and the text content of the option is also set to the value of the item</option>

A

.<option><%= item %></option>:

29
Q

Type of vulnerability where an attacker injects malicious scripts into a web app tht are then executed by unsuspecting users visiting the affected page. this can lead to unauthorized actions or data theft.

A

Cross-Site Scripting (XSS)

30
Q

To prevent Cross-Site Scripting attacks - Express.js provides security measures like escaping user input, using secure templating engines and employing content security policies CSP

A

To restrict execution of scripts.

31
Q

An attack where the attacker tricks the victim into performing uninted actions on a web application while authenticated

occurs if the app does not vailadate the origin of the request allowing unauthorized requests to be executed on behalf of the victim

A

Cross-Site Request Forgery (CSRF)

32
Q

Express.js provides protection against CSRF through middleware - unique values included in forms or requests to verify their authenticity

A

Cross-Site Request Forgery tokens

33
Q

The process of ensuring that the data submitted by users through forms or ither input mechanisms meets the expected criteria and is safe to use

A

User Input Validation

34
Q

The real language of programmatic data management is

A

database

35
Q

Meas the syntax you’ll use for interacting with sqlite database will closely parallel how you’d do it with MariaDB, Amazon Aurora, Oracle, or MS SQL Server

A

SQL

Structured Query Language

36
Q

will create a new table and add a single entry

A

db.js

37
Q

will add a second entry to the table

A

db_add.js

38
Q

will change the details for on or two entries

A

db_modify.js

39
Q

will remove an entry

A

db_delete.js

40
Q

With this in place when this method is run itl automatically hand the escaping of the variable value, prventing SQL injection.

A

db.run()

41
Q

used to UPDATE a record

A

updateQuery