server-side development Flashcards

1
Q

what does node.js do

A

runs js on the server side

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

what are http methods

A

textual commands passed via http protocols between the client and the browser

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

GET

A

requesting/retrieving content

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

POST

A

sending data and retrieving content

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

what is a web server

A

software that runs on the server or cloud infrastructure

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

what does the web server do

A

handles http requests
listens for tcp connection requests from clients

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

what is a port

A

communication endpoints for a host on a network using tcp

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

how many processes can be assigned to a port at once

A

1

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

how many well known ports are there

A

1023

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

what is the software loopback ip

A

127.0.0.1

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

what are endpoints in node

A

code intended to receive a request from a client

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

how can endpoints in node be distinguished

A

via the url and the http method

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

node routes

A

the connection of the http request to the endpoint

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

response object

A

what you send back to the client

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

request object

A

what came in from the client/browser
an object is created to encapsulate this information

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

what is AJAX and what does it do

A

asynchronous javascript and xml
allows content to be updated after loading a page without intervention from the user which allows for dynamic pages

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

how does AJAX work

A

after the page has loaded we use js at the client side to query the server
the server responds with content which is processed by js and if we need to the page is updated without being reloaded

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

why dont we need html in ajax

A

we dont need to render the page

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

what is axois

A

a http client library that runs in browser and on node.js that simplifies querying a web service in js

20
Q

how do we handle errors in axios

A

promises; then and catch

21
Q

what does express do

A

simplifies handling http requests in js/node.js

22
Q

+ url encoded parameters

A

the simplest way of passing data

23
Q

how do we pass multiple parameters in url encoded parameters

A

separating them with &

24
Q

res.end (express)

A

ends the response ; nothing else should follow it

25
res.send (express)
can be used multiple times to construct a response
26
CORS
cross origin response sharing: a security feature that allows or restricts resources on a web page to be requested from another domain outside the domain where they originated from
27
what is the difference between GET and http POST
get encodes the data in a url whilst with post the data is encoded in a http request
28
what is http post used for
sending content of a html form to the server
29
what does the json parser look like and what is its role
app.use(express.json()); parses the incoming requests
30
how do we access incoming data with json
const name = req.body.q
31
when should POST be used and why
when wanting to send data not 'visible' so more secure no restriction on data length
32
when should we use GET and what are the downsides of using it
when retrieving web pages no security kept in browser history
33
what is the format of json when sending data using POST
key value pairs e.g. {"str": "words"}
34
what is the role of web sockets
allow you to keep the connection open between the client and server in js so the server can send back data to the client as necessary
35
how do we set up web sockets on the server
we use a server object to create it a http connection is 'upgraded' to a web socket as requested we handle the socket like a get (wss.on) and send responses to the client then disconnect when done (ws.close())
36
what module is used by node to interact with files
fs
37
how do we read and send files with node
readFile(filename, callback) sendFile(filename, callback)
38
what does _dirname mean when using files
the path where the currently running script is
39
. (fs module)
current directory
40
..(fs module)
up a directory
41
/(fs module)
filesystem root
42
what is the point of a db
allows you to store and access data efficiently
43
sql as a relational database
data is in tables
44
sql as non-procedural
you specify what to do not how to do it
45
when do we use sqlite
for smaller embedded applications
46
.verbose() (sqlite)
gives more info on the errors