Giter Site home page Giter Site logo

express_training's Introduction

Express training

Instructions

Use just node, express and babel-node to run your server.
Use morgan middleware to output requests.
Use body-parser middleware.

First part

  • Build an express server made of below services :
  1. GET /ping returns json “{ “ping”: “pong” }”

  2. GET /add/<X>/<Y> returns json { result: X+Y }
    If X or Y cannot be casted to numbers, returns 500

  3. Do the same with GET /add/?op1=X&op2=Y

  4. The same with GET /add/?ops=[X, Y]

  5. Again with POST /add body should be { values: [a,b,c,d,...] }
    returns { result: sum(values) }
    returns 500 with error message { error: message }

  6. GET / returns ‘./public/index.html’.
    See ‘express.static’ middleware.

Second part

  • Craft a minimalist version of a todo lists server :

Should returns 500 code in case of an error

const todos = [];
// todo = { id, label }
  1. GET /api/todos returns [ ...todos ];

  2. POST /api/todos

body = { todo : { label1 } }

todos.push(todo); returns todo;

  1. PUT /api/todos
body = { id, label };

update existing todo returns todo.

  1. DELETE /api/todos/id remove todo’s id from todos returns { id }

Let’s code ....

express_training's People

Watchers

James Cloos avatar Matthias Leconte 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.