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 which allows for dynamic pages
happens without intervention from the user

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
Q

res.send (express)

A

can be used multiple times to construct a response

26
Q

CORS

A

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
Q

what is the difference between GET and http POST

A

get encodes the data in a url whilst with post the data is encoded in a http request

28
Q

what is http post used for

A

sending content of a html form to the server

29
Q

what does the json parser look like and what is its role

A

app.use(express.json());
parses the incoming requests

30
Q

how do we access incoming data with json

A

const name = req.body.q

31
Q

when should POST be used and why

A

when wanting to send data
not ‘visible’ so more secure
no restriction on data length

32
Q

when should we use GET and what are the downsides of using it

A

when retrieving web pages
no security
kept in browser history

33
Q

what is the format of json when sending data using POST

A

key value pairs
e.g. {“str”: “words”}

34
Q

what is the role of web sockets

A

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
Q

how do we set up web sockets on the server

A

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
Q

what module is used by node to interact with files

37
Q

how do we read and send files with node

A

readFile(filename, callback)
sendFile(filename, callback)

38
Q

what does _dirname mean when using files

A

the path where the currently running script is

39
Q

. (fs module)

A

current directory

40
Q

..(fs module)

A

up a directory

41
Q

/(fs module)

A

filesystem root

42
Q

what is the point of a db

A

allows you to store and access data efficiently

43
Q

sql as a relational database

A

data is in tables

44
Q

sql as non-procedural

A

you specify what to do not how to do it

45
Q

when do we use sqlite

A

for smaller embedded applications

46
Q

.verbose() (sqlite)

A

gives more info on the errors