Giter Site home page Giter Site logo

node-study's Introduction

node-study

Build Status Coverage Status Node.js Version

Just for learning node.js.

主要是学习 Node.js 部分库的使用,以及如何构建自动化测试相关内容。

构建

node version ≥ 8.12.0

cd node-study
npm install
npm start

本工程使用了eslint代码规范模块,如果需要使用需要安装eslint模块:

npm install eslint -g

工程结构

app.js:        启动文件,或者说入口文件
package.json:  存储着工程的信息及模块依赖,当在 dependencies 中添加依赖的模块时,运行npm install,npm 会检查当前目录下的 package.json,并自动安装所有指定的模块
node_modules:  存放 package.json 中安装的模块,当你在 package.json 添加依赖的模块并安装后,存放在这个文件夹下
public:        存放 image、css、js 等文件
routes:        存放路由文件
views:         存放视图文件或者说模版文件
bin:           存放可执行文件

学习笔记

  1. express 教程多看API文档

  2. 配置文件模块工具 config-lite

    1. 环境变量设置可跨平台应用解决windows与Linux不兼容问题 cross-env
  3. 日志中间件 morgan

    1. 日志文件每日新建一份存储 rotating-file-stream

    关于rotating-file-stream有个需要注意的地方是,如果设置每日新建一个文件存储,它日志存储方式是先将新的日志会在默认的文件里,比如这里file.log中,到时间新建日志文件的时候它会把符合条件的日志全部拷贝进去,新日志仍然会放在file.log中。

    另外有个配置需要注意下:initialRotation

  4. 自动化测试模块mocha

    1. should
    2. supertest
  5. cookie-parser 模块(已移除该模块,原因看这里)

    需要注意的一点就是,使用时可以指定一个类似密钥的字符串,如果不使用,则获取cookie是用req.cookies,如果使用了密钥,则获取cookie是要用req.signedCookies

  6. express-session模块

    cookiesession的介绍,其中区别可以看这里,讲得很是通俗易懂

    session-file-store一个文件存储session信息,可用来测试。

  7. express-validator模块

  8. 在线查看API接口说明Swagger 首页swagger.json是API接口文档的配置,感觉写起来也不是一件容易的事啊。但查看确实是很方便!

  9. 关于 Promise 的一点说明

    主要是在非异步函数中链式调用 Promise 对象的问题。如何保证一直 .then().then().then()... 下去。

node-study's People

Contributors

missingmeow avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.