Code Monkey home page Code Monkey logo

todolist-backend's Introduction

TodoList-Backend

目录

API

查询

查询所有 todo

GET /todo

返回含所有 todo 的数组

查询标题含 kw 的 todo

GET /todo?kw={kw}

返回

  1. 如果 kw 不为空,返回标题含 kw 的 todo
  2. 如果 kw 为空字符串,返回空数组
  3. 如果 kw 为其他,返回 400 Bad Request

查询特定类型的 todo

GET /todo?type={?}

查询完成或未完成的 todo

GET /todo?completed={true|false}

返回含所有 {completed} 的 todo 的数组

查询特定时间范围的 todo

粒度:天

GET /todo?start_time={?}&end_time={?}

查询特定 todo

GET /todo/{id}

返回

  1. 如果 id > 0 && id <= Number.MAX_VALUE

    • 如果 id 对应 todo 存在
    interface Todo {
        Id: number;
        Content: string;
        Note: string | null;
        CreationTime: Timestamp;
        ReminderTime: Timestamp | null;
        Priority: Priority;
        Flagged: boolean;
        Completed: boolean;
    }
    • 否则返回 404
  2. 否则 400 Bad Request

增加

新增一个 todo

POST /todo

Payload:

const TodoInstance: TodoPartial = {
    Content: '',
    Note: null,
    ReminderTime: null,
    Priority: 0,
    Flagged: false,
    Completed: false
} as const;

type TodoPartial = { [P in keyof Todo as Exclude<P, 'Id'> & Exclude<P, 'CreationTime'>]?: Todo[P] }
  1. 如果 TodoPartial 合适

    • 返回 201 Created 和 Location: /todo/:id
  2. 否则返回 400 Bad Request

修改 todo

PUT /todo/{id}

Payload:

const TodoInstance: TodoPartial = {
    Content: '',
    Note: null,
    ReminderTime: null,
    Priority: 0,
    Flagged: false,
    Completed: false
} as const;

type TodoPartial = { [P in keyof Todo as Exclude<P, 'Id'> & Exclude<P, 'CreationTime'>]?: Todo[P] }

返回

  1. 如果 id 对应 todo 存在

    • 204 No Content,头部 Content-Location: /todo/{id}
  2. 如果收到的 todo 不合适,返回 400

  3. 否则返回 404

删除

DELETE /todo/{id}

  1. 如果 id > 0 && id <= Number.MAX_VALUE

    • 如果 id 对应 todo 存在

      • 返回 200 OK 以及删除条目的 id
    • 否则返回 404

  2. 否则返回 400 Bad Request

todolist-backend's People

Contributors

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