Coder Social home page Coder Social logo

201-nodejs-web-practice's Introduction

基于 express + mongoose 的api 练习

运行方式

  1. 检查 config/default.json 中参数配置是否正确

  2. 在命令行中执行如下命令

    npm start
  3. 在浏览器中测试 http://localhost:3000

  4. 在浏览器中测试 http://localhost:3000/items

练习要求

重要:本题包含四个篇目:基础,进阶,提高,出栈,做完一个篇目后,需要到 https://jinshuju.net/f/27Zpwx 提交做题记录

基础篇

  1. 创建model: item 完成下列接口

    GET /items # 获取全部item
    GET /items/:id	# 获取一个item
    POST /items #增加 一个item
    DELETE /items/:id # 删除一个item
    PUT /items/:id	# 更新一个item
    
  2. 创建Model: category,category 与 item 为一对多关系,并参照上面完成相应接口

  3. 创建Model: cart,cart 与 item 为多对多关系,并参照上面完成相应接口

进阶篇

  1. 自己编写刷数据库脚本创建上述数据库,并完成功能
  2. 用 supertest + mocha 完成上述接口的集成测试
  3. 用 inspector 调试功能解决问题

提升篇

  1. 创建Model: user, 可以实现用户的注册和登录功能,user和cart是一对一的关系

  2. 写一个中间件,实现如下功能

    - 没有登录的用户只能访问 GET 类型接口
    - 登录的用户可以访问所有接口
    - 用户只能访问自己的 cart
    
  3. 从一个空库开始完成上述过程

  4. 提出一个合理需求,要求用到 discriminator/populate/unwind,并完成之

出栈篇

待定。。。

201-nodejs-web-practice's People

Contributors

banshengbushu avatar

Watchers

 avatar  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.