JumpStart – CRUD, Testing CRUD

CRUD note: __v is versioning, only updates on .save() .save(), .find(), .where, findByIdAndUpdate(), findOneAndDelete() Queries are Not Promises Mongoose queries are not promises. They have a .then() function for co and async/await as a convenience. However, unlike promises, calling a query’s .then() can execute the query multiple times. Testing CRUD Schema Validation validates only on .save() for the rest of the methods, set runValidatorsoption to … Continue reading JumpStart – CRUD, Testing CRUD

JumpStart – History of CI, Intro to MongoDB

CLI && vs & (in shell) && ( waits for first condition is true) & (parallel process, runs both whether first condition passes) to set up env var for both windows and unix you can use cross-env there’s also another utility for env var to wait-on command to be finished npm-run-all CLI tool to run multiple … Continue reading JumpStart – History of CI, Intro to MongoDB

JumpStart – sending ACAO and CI using travis CI

Client -> sends (origin: yourwebsite.netlify.com) -> CORS –> Books API (server) –> ACAO (Access-Control-Allow-Origin) –> If ACAO, SUCCESS! IMPORTANT! Insomnia does not give CORS error presentation: hasCorrectAttributes (jest) filter results: .some(), .every() pull request fork, edit and commit in new branch -> create pull request –> create issue (paste in #of pr in write) backtick … Continue reading JumpStart – sending ACAO and CI using travis CI

JumpStart – Testing our Express server (supertest)

put/ patch (implementation is up to server) Supertest uses superagent to use html methods (.post, .query({format:’json’}) Using jest expect (green indicates jest expect): .expect(202) .then(res => { expect(res.body.id).toEqual(expect.any(String)); expect(res.body.name).toEqual(“Alfred”); expect(res.body.subjects).toEqual(expect.any(Array)); }); versioning exists in api app.use(“/app/v1….”) For… in loops over prototype chain as well (eg: objects constructed from class) so use Object.entries [[k,v], [k,v]] Object.keys … Continue reading JumpStart – Testing our Express server (supertest)

JumpStart – Building an Express server

  Insomnia has an environment you can set baseurl and port also sub environments MIDDLEWARE express has a built-in body-parser: express.json uses body-parser as middleware and support lotsa other middleware https://expressjs.com/en/resources/middleware.html each packet contains: header, data, checksum https://en.wikipedia.org/wiki/Transmission_Control_Protocol express doesn’t know how to read the body content so the header informs it of the content … Continue reading JumpStart – Building an Express server

JumpStart – Intro on Creating your on RESTFUL API

RPC vs RESTful (remote protocol call vs respresentational state) (function driven vs resource driven) eg: example.com/createStudents vs example.com/students .fetch() does not treat status code ‘errors’ (400s, 500s) as an error axios.get() catches status code ‘errors’ CORS Cross-origin (includes different subdomains) to prevent malicious websites from cross origins, client can send the OPTIONS request with Origin: … Continue reading JumpStart – Intro on Creating your on RESTFUL API

JumpStart – Intro to the Web

CRUD – Create Read Update Delete CORS (Cross Origin Resource Sharing) API TOKEN – public, private DARPA – US military Project Internet TCP/IP — Internet Protocol Suite (eg HTTP, IMAP (mail), SSH, etc) WWW – HTTP W3W WHATWG TCP – reliable, UDP – less reliable (video stream) IPV4 – IPV6 (more numbers in V6) HTTPS … Continue reading JumpStart – Intro to the Web

JumpStart – React Fetching Data

Axios 3rd Party Lib larger size lots of helper methods OK error handling Fetch API Built in to browser smaller size write everything yourself weird error handlingcreate-react-app comes with dotenv module Please do this to hide your API key (in prod, this can be added to the site env variables): create a .env.local file for … Continue reading JumpStart – React Fetching Data

JumpStart – React form Validation and getting data when component is mounted

This is a continuation of yesterday’s post on React. As today’s lesson is a lab (code-along), the post will not be comprehensive. Form Validation using Joi: Joi-browser import joi from “joi-broswer” schema = {   _id:Joi.string(),     .integer()     .min(1)     .required(),   imageUrl:Joi.string()   .uri({     relativeOnly:true   })   … Continue reading JumpStart – React form Validation and getting data when component is mounted

Design a site like this with WordPress.com
Get started