Web Development Flashcards

1
Q

Promises vs async/await scope of asynchronism

A

The biggest difference I noticed between promises and async/await is the scope of the asynchronism.

https://levelup.gitconnected.com/async-await-vs-promises-4fe98d11038f

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

advantage of async/await over promises

A

https://www.freecodecamp.org/news/async-await-and-promises/

run async code that reads like synchronous

https://medium.com/front-end-weekly/callbacks-promises-and-async-await-ad4756e01d90

const makeRequest = () =>
  getJSON()
    .then(data => {
      console.log(data)
      return "done"
    })

makeRequest()

const makeRequest = async () => {
  console.log(await getJSON())
  return "done"
}

makeRequest()

  1. Concise and clean

Look at how much code we didn’t write! Even in the contrived example above, it’s clear we saved a decent amount of code. We didn’t have to write .then, create an anonymous function to handle the response, or give a name data to a variable that we don’t need to use. We also avoided nesting our code. These small advantages add up quickly, which will become more obvious in the following code examples.

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

What is Apollo GraphQL?

What is GraphQL?

Which databases does GraphQl Use?

A

Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Use it to fetch, cache, and modify application data, all while automatically updating your UI.

Thousands of developers have told us that Apollo Client excels at managing remote data, which equates to roughly 80% of their data needs. But what about local data (like global flags and device API results) that make up the other 20% of the pie? Apollo Client includes local state management features out of the box, that allow you to use your Apollo cache as the single source of truth for data in your application.

By leveraging Apollo Client’s local state functionality, you can add client-side only fields to your remote data seamlessly and query them from your components. In this example, we’re querying the client-only field isLiked alongside our server data. Your components are made up of local and remote data, now your queries can be too!

Apollo client provides support for graphql syntax

built-in integration with React

GraphQL is a query language (that’s what the “QL” stands for) for APIs and a runtime for fulfilling those queries with your existing data. Basically, it is used to load data from a server to a client – it’s a way to get data from an API into your application.

GraphQL reduces network requests by allowing us fetch or retrieve all the data we need in a single query.

The main feature of GraphQL is to be able to send a query specifying only the information you need and get exactly that.

It lets the client specify exactly what data it needs. It makes it easier to aggregate data from multiple sources. It uses a type system to describe data.

GraphQL allows making multiple resources request in a single query call, which saves a lot of time and bandwidth by reducing the number of network round trips to the server. It also helps to save waterfall network requests, where you need to resolve dependent resources on previous requests.

see [Online] ReactJS Monthly Meetup
Building with Apollo and GraphCMS

This is a misconception, GraphQL is a query language for APIs - not databases. In that sense it’s database agnostic and can be used with any kind of database or even no database at all.

GraphQL is a query language and server-side runtime for application programming interfaces (APIs) that prioritizes giving clients exactly the data they request and no more. GraphQL is designed to make APIs fast, flexible, and developer-friendly.

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

CI/CD

A
  1. CI - build and test
  2. CDelivery - deployment

collection of practices that enable application development teams to deliver code changes more frequently and reliably.

CI is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily

Each integration is verified by automatic build, including test

Integration is when feature branch is merged with the main branch.

But CD can either mean continuous delivery or continuous deployment.

Building means starting with source files produced by developers and ending with things like installation packages that are ready for deployment.

Once developers have written code for a site, they need to place that code on the web servers. It’s called code deployment.

Github actions Automate your GitHub workflows

Github Actions enables you to create custom software development lifecycle workflows directly in your Github repository. These workflows are made out of different tasks so-called actions that can be run automatically on certain events.

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

headless cms

graphcms vs netlifycms

A

A headless CMS is a content management system that provides a way to author content, but instead of having your content coupled to a particular output (like web page rendering), it provides your content as data over an API. … These are usually called “Headless” or “API-first” CMSes.

GraphCMS is a GraphQL Based Headless Content Management System. It lets you build a hosted GraphQL backend for your apps and gives you all the tools you need to manage your content;

Netlify CMS: Open source content management for your Git workflow. It is built as a single-page React app.

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

ngrok

what is localhost

A

share your localhost with other developers,

what is localhost? https://www.youtube.com/watch?v=ahYgoV8MDtg

allows to channel your localhost into a temporary url
update real time, it will auto refresh
4 easy steps on the website
./ngrok http 3000
gives you public url anyone can access 
has a lot of features - see docs

https://www.youtube.com/watch?v=DCxt9SAnkyc&t=307s&ab_channel=Pentacode

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

What is async javascript?

A

Asynchronous code = code that can start now and finish later
Blocking code = statement that fetches data stalls the program, it blocks next statement from running until it’s complete
https://www.youtube.com/watch?v=ZcQyJ-gxke0
You give that statement a callback that can complete when data comes back

Async fun - browser takes request and handles it outside of the scope of the single thread in another part of the browser
Puts callback to the side too
Network request is now outside of the thread, so the js can carry on down the queue
The data request is still going on on the side

Simplistic explanation - look into event queue and call stack to go deeper
setTimeout to emulate a network request is non blocking and asynchronous

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

API endpoints

A

API endpoints are urls that server exposes to us to make network requests to for data

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

callback

A

When you need to execute code after something has happened, not sequentially
Asynchronous
Callbacks
Function that is evoked when something else happened
Achieved by passing in a function into function that is called back after something is executed
This is possible bc js supports higher order functions
Anonymous fs are defined at the time they are passed in
In a setTimeout you can call the name of the function or define the function within
Callbacks are passed in to event listeners, they only are called after an event happens
For example when a click event happens on that function
Take a data, and only perform callback on the ones that of type east/

example:
students data with student name, score, and school
let processStudents = function(data, callback){
loop through the data and if element === east
callback(el)
}
processStudents(students, function(obj){
if score is more than 60, console.log passed
})

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

ESlint

A

Linting is the automated checking of your source code for programmatic and stylistic errors. This is done by using a lint tool (otherwise known as linter). … The term linting originally comes from a Unix utility for C. There are many code linters available for various programming languages today. Did you mean: what does eslint do

ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.

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

code coverage

A

Code coverage is the percentage of code which is covered by automated tests. Code coverage measurement simply determines which statements in a body of code have been executed through a test run, and which statements have not. … Code coverage is part of a feedback loop in the development process.

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

what is react native web?

A

This is exactly the problem the React Native for Web project is trying to solve. Instead of forcing you to maintain two separate code bases for your mobile and web apps, or making a hybrid app, with all its compromises.

React Native for Web is intended to let you write a single app that runs in a browser using standard web technologies, or on iOS and Android as a real native mobile app.

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

Minimizing Security Risks when designing your app

A

a lot of developers think of security as an add on that’s done after
can you always see from the outside if the data is security
equifax is popular for trustful security
breached in 2017, now have they have best security team
vulnerability was known for 2 years
usual tools and frameworks
I don’t want to scan my code every time I push in production
invest in automating
how to prevent injections?
learn basics of security while learning how to code
your security scans will come back bad, you’ll have to rewrite it so it’s compliant
security is parallel to functionality
depends how much time
can you do audit log separate from application log
active monitoring so you can shut it down as it’s happening
mechanism of forensics, if you detect it early
have relevant data for forensics to take place
don’t argue that breach will happen, just prepare for it
it’s a matter of when
impersonating ceo
with ai it’ll be a problem
people are getting creative

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

When to use React Expo?

A
no xcode/android studio
* no headaches with deployment certificates or configurations
OTA
* publish over the air
* no need to re-approval for updates
Seamless deploy
* 2 commands to deploy
Push notifications
* Freedom to choose, no firebase push notifications
Native code
* Usually no access to native code
Too much magic
* Maybe training wheels not needed?

you can always exit expo and continue in cli, you loose simplicity if you do that
all when you run through Xcode something fails in build, but expo eliminates all of that and your app is in the store

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

What is GatsbyJS?

Progressive web app

A

GatsbyJS, on the other hand, is a static progressive web app (PWA) generator that offers code and data splitting out of the box. To boost performance, GatsbyJS loads only critical HTML, CSS, JavaScript, and other data. Once loaded, it prefetches resources for other pages you might navigate to.

React is a library that is meant to provide a certain set of core functionality for developers to leverage. It is intended to be lightweight and broadly applicable.

Gatsby, on the other hand, is, “a static PWA (Progressive Web App) generator. You get code and data splitting out-of-the-box. Gatsby loads only the critical HTML, CSS, data, and JavaScript so your site loads as fast as possible. Once loaded, Gatsby prefetches resources for other pages so clicking around the site feels incredibly fast.”

Gatsby is a static site generator that leverages React.

Progressive web apps are websites that look and feel like an app. This means users can access all information and capabilities without downloading a mobile app. Instead, progressive web apps use modern web technology to deliver app-like experiences to users, right in their browsers.

Important to read every time: https://www.actminds.com/blog/pwa/

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

What are static sites?

A

A note before we begin: because the rendering all happens on the client side (unless you’re using server-side rendering), React is technically “static” as far as your web server is concerned. The files that you host on your web server don’t change in response to requests like PHP would. However, this is largely a technicality, because the pages are still rendered dynamically, just on the client.

In depth: https://www.cloudsavvyit.com/5418/how-to-generate-static-websites-with-react/

17
Q

single page vs multi page applications

A

Single-Page Application
A single-page application is an app that works inside a browser and does not require page reloading during use. You are using this type of applications every day. These are, for instance: Gmail, Google Maps, Facebook or GitHub.
SPAs are all about serving an outstanding UX by trying to imitate a “natural” environment in the browser — no page reloads, no extra wait time. It is just one web page that you visit which then loads all other content using JavaScript — which they heavily depend on.
SPA requests the markup and data independently and renders pages straight in the browser. We can do this thanks to the advanced JavaScript frameworks like AngularJS, Ember.js, Meteor.js, Knockout.js .
Single-page sites help keep the user in one, comfortable web space where content is presented to the user in a simple, easy and workable fashion.

Multi-Page Application
Multiple-page applications work in a “traditional” way. Every change eg. display the data or submit data back to server requests rendering a new page from the server in the browser. These applications are large, bigger than SPAs because they need to be. Due to the amount of content, these applications have many levels of UI. Luckily, it’s not a problem anymore. Thanks to AJAX, we don’t have to worry that big and complex applications have to transfer a lot of data between server and browser. That solution improves and it allows to refresh only particular parts of the application. On the other hand, it adds more complexity and it is more difficult to develop than a single-page application.

18
Q

GraphQl vs Rest

A

Data Fetching with REST vs GraphQL
With a REST API, you would typically gather the data by accessing multiple endpoints. In the example, these could be /users/ endpoint to fetch the initial user data. Secondly, there’s likely to be a /users//posts endpoint that returns all the posts for a user. The third endpoint will then be the /users//followers that returns a list of followers per user.

With REST, you have to make three requests to different endpoints to fetch the required data. You’re also overfetching since the endpoints return additional information that’s not needed.

In GraphQL on the other hand, you’d simply send a single query to the GraphQL server that includes the concrete data requirements. The server then responds with a JSON object where these requirements are fulfilled.

Using GraphQL, the client can specify exactly the data it needs in a query. Notice that the structure of the server’s response follows precisely the nested structure defined in the query.