Coder Social home page Coder Social logo

my-blog's Introduction

https://github.com/mhbseal/blog

https://github.com/tyrocjh/my-blog-demo

technology: gulp, react, react-router, fetch, express, mooogoose, ckeditor, jwt, bcrypt, passport, spider

gulp: http://www.dbpoo.com/getting-started-with-gulp/

ckeditor: http://sdk.ckeditor.com/samples/fileupload.html

spider: http://www.cnblogs.com/coco1s/p/4954063.html?utm_source=tuicool&utm_medium=referral


spider data: comment, user

comment model why use this struct? article: { id: Schema.Types.ObjectId, typePath: String },

css.map

upload.js / model article.js / component admin article.js ...

list page 删除一条数据后,需要重新发送请求,渲染页面吗

编辑的时候可以传值,不用再call一次api?

list page (article list / articletag list) abstract

router controller crud/err abstract

abstract anything can be abstract

<script src="http://cdn.ckeditor.com/4.5.9/standard-all/ckeditor.js"></script>

redis??

node task -> spider

desktop and mobile style improve

前后台应该分开2个入口文件(这样可以分开加载不同的js、css文件)


next prj: front-end first(data mock): es6 react-redux(redux-devtools, reducer?), ant-design, webpack+gulp, docker, comment plugin react-boilerplate? front-back-end-seperate-use-nginx


fetch-api get method with params: [https://fetch.spec.whatwg.org/#fetch-api] var url = new URL("https://example.org/api"), params = { first: "x", second: "y" } Object.keys(params).forEach((key, value) => { url.searchParams.append(key, value) }) fetch(url).then(/* ... */)

function urlWithParams(urlString, params={}) { var url = new URL(urlString); var searchParams = new URLSearchParams(); Object.keys(params).forEach((key) => { searchParams.append(key, params[key]); }); url.search = searchParams.toString(); return url.toString(); }


路径(Endpoint) 路径又称"终点"(endpoint),表示API的具体网址。 在RESTful架构中,每个网址代表一种资源(resource),所以网址中不能有动词,只能有名词,而且所用的名词往往与数据库的表格名对应。一般来说,数据库中的表都是同种记录的"集合"(collection),所以API中的名词也应该使用复数。 举例来说,有一个API提供动物园(zoo)的信息,还包括各种动物和雇员的信息,则它的路径应该设计成下面这样。 https://api.example.com/v1/zoos https://api.example.com/v1/animals https://api.example.com/v1/employees

GET /zoos:列出所有动物园 POST /zoos:新建一个动物园 GET /zoos/ID:获取某个指定动物园的信息 PUT /zoos/ID:更新某个指定动物园的信息(提供该动物园的全部信息) PATCH /zoos/ID:更新某个指定动物园的信息(提供该动物园的部分信息) DELETE /zoos/ID:删除某个动物园 GET /zoos/ID/animals:列出某个指定动物园的所有动物 DELETE /zoos/ID/animals/ID:删除某个指定动物园的指定动物

过滤信息(Filtering) 如果记录数量很多,服务器不可能都将它们返回给用户。API应该提供参数,过滤返回结果。 下面是一些常见的参数。 ?limit=10:指定返回记录的数量 ?offset=10:指定返回记录的开始位置。 ?page=2&per_page=100:指定第几页,以及每页的记录数。 ?sortby=name&order=asc:指定返回结果按照哪个属性排序,以及排序顺序。 ?animal_type_id=1:指定筛选条件

状态码(Status Codes) 服务器向用户返回的状态码和提示信息,常见的有以下一些(方括号中是该状态码对应的HTTP动词)。 200 OK - [GET]:服务器成功返回用户请求的数据,该操作是幂等的(Idempotent)。 201 CREATED - [POST/PUT/PATCH]:用户新建或修改数据成功。 202 Accepted - []:表示一个请求已经进入后台排队(异步任务) 204 NO CONTENT - [DELETE]:用户删除数据成功。 400 INVALID REQUEST - [POST/PUT/PATCH]:用户发出的请求有错误,服务器没有进行新建或修改数据的操作,该操作是幂等的。 401 Unauthorized - []:表示用户没有权限(令牌、用户名、密码错误)。 403 Forbidden - [] 表示用户得到授权(与401错误相对),但是访问是被禁止的。 404 NOT FOUND - []:用户发出的请求针对的是不存在的记录,服务器没有进行操作,该操作是幂等的。 406 Not Acceptable - [GET]:用户请求的格式不可得(比如用户请求JSON格式,但是只有XML格式)。 410 Gone -[GET]:用户请求的资源被永久删除,且不会再得到的。 422 Unprocesable entity - [POST/PUT/PATCH] 当创建一个对象时,发生一个验证错误。 500 INTERNAL SERVER ERROR - [*]:服务器发生错误,用户将无法判断发出的请求是否成功。

GET /tickets/12/messages - Retrieves list of messages for ticket #12 GET /tickets/12/messages/5 - Retrieves message #5 for ticket #12 POST /tickets/12/messages - Creates a new message in ticket #12 PUT /tickets/12/messages/5 - Updates message #5 for ticket #12 PATCH /tickets/12/messages/5 - Partially updates message #5 for ticket #12 DELETE /tickets/12/messages/5 - Deletes message #5 for ticket #12


API的身份认证应该使用OAuth 2.0框架



项目网 shixian.com

my-blog's People

Contributors

tyrocjh avatar

Watchers

James Cloos 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.