background

A front-end that doesn’t know Node is not a good product manager

In addition to reviewing front-end knowledge during the period of leaving, I used my spare time to learn Node backstage development systematically. This project will record a learning process of Node, from native Node to write a server, to Express, Koa2 learning, a deeper understanding of Node, expand knowledge horizon, interested can click a “like” to pay attention to. This project is aimed at some students who have front-end foundation and have used Node. If you want to further study, you can join me.

In the learning process, I will use three ways to implement a simple tool TODOList, mainly involving some simple API interface, registration, login, item add, delete, change, modify personal information, set synchronization…

A study plan

Said I, first have to understand the node before the background, but also limited to the solution (no) (write) to (have) said, and recently in the simple node Koa and node. Js development of actual combat related knowledge of books, gives the following node study plan this plan may not be very professional very thorough, there may be missing, Welcome Daniel to point out and call the roll.

Project introduction

This study, will develop a small project todoList (really do not know what to write project), will only involve some basic functions (or too dishes), can think of at present is the following, if you have better comments welcome to leave a message in the comment section.

Based on the environment

  • PC Node versionNode: v10.24.1
  • "Nodemon" : "^ 2.0.12"

Nodemon allows you to avoid frequently launching projects during development. It can listen for project changes and execute, which is great for local development and debugging.

Configuration project Startup

Add the following command to srcipt under package.json

  "start": "node app.js"."dev": "nodemon app.js"
Copy the code

The start command is used to start a project

The dev command is used for local development

Create a simple server

const http = require('http');
const path = require('path');

// Start port
const port = 1024;

// Create a server
const server = http.createServer((req, res) = > {
  Set the response header charset= UTF-8 to avoid garbled Characters
  res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8'});
  // res.write('hello word! ')
  res.write('Here we go, little boy! ')
  res.end()
});


// Start the server
server.listen(port, () = > {
  console.log('Server is running on http://127.0.0.1:${port}/ `);
})
Copy the code

Start the project

  // init
  cnpm i / yarn 
  
  // start
  npm run start

  // dev
  npm run dev
Copy the code

Write in the last

This project is for study only, no other purpose, the big guys just enjoy it. If you feel that the project is helpful to you, welcome to like the following. After the background series is finished, there will be a project to make a desktop Application using Vue3 + Electron(yes, I am not using Vue3 in 1202), or to open a small program /app. If you are interested, please pay attention to the following.

Prohibit reprint without permission 💌

Github address of the project

TODO

  • Native Node version (in progress…)
  • Express version
  • Koa2 version
  • Database MD compilation
  • Test MD writing
  • Deployment MD writing