Summary of setting up Express and MongoDB as Backend Server
Install Express.js and MongoDB as backend server
- Create a folder with your project name.
- cd to the folder that you just created.
- Run npm init.
- For the backend, the start poinst is server.js
- License : βMITβ
After above type in, you will get a package.json file under the folder.
-
Install dependencies:
npm i express body-parser mongoose concourrently cors dotenv
- Express is a Node.js web application server framework, designed for building single-page, multi-page, and bybrid web application will be creating routers or APIs
- body-parser is a middleware in order for application to be able to ready the body of an incoming JSON object. If express.js version is 4.16+, the exrpess.js package included this middleware. so you do not need to to install this.
- mongoose is an ODM (Object Data Modeling) library for MongoDB and Node.js.
It manages relationships between data, provides shcema validation, and is used to translated between objects in code and the represenation of those objects in MongoDB.
- concurrently, this can run multiple comaands concurrently. After this is installed, you can set up your NPM start script (in package.json file) to run multiple commands by spearating each individual command with quotes.
You can reference this article to learn more 4 Solutions to Run Multiple Node.js or NPM commands Simultaneously
- cors stands for Cross-origin resource sharing, it allows AJAX requests to skip the Same-origin police and access resources from remote hosts.
The cors package provides an Express middleware that can enable CORS with different options.
- detenv loads environment variables from a .env file into process.env. This makes developmenet simpler. Instead of setting environment variables on our app, they can be stored in a file, it is .env file.
Posted by Joy Lin on February 17, 2020
Treaps ?! - Part II
Treap = Tree + Heap
As suggested by name, Treap is the combination of Tree and Heap. Teap is a Self-balancing Binary Search Tree or a Randomized Binary Search Tree.
Posted by Joy Lin on February 9, 2020
Treaps ?! - Part 1
What is Treaps?
In short, Treap is simply a Self-balancing binary search tree., but of course, much cooler.
Posted by Joy Lin on February 3, 2020
Note of binary tree traverse and sorting algorithms
This summary is based on the following to lay out the most popular algorithms of traversing of binary tree, and sortings.
Posted by Joy Lin on January 27, 2020