Skip to content

Blacate/dwz

Repository files navigation

dwz - 个人短网址小应用

preview
ps:click the logo for links list

username:username
password:password

1. Dependencies

2. How to run

$ npm install  			 			# install dependencies
$ cp config.example.js config.js 	# set site configuration
$ npm run dev    		 			# start Node Server at port 3000

3. API

目录:

  1. 获取api说明
  2. 添加短网址
  3. 检查tinyurl是否被使用
  4. 登录
  5. 修改短网址
  6. 删除短网址
  7. 获取所有短网址

文档:

1.获取api说明

请求

GET /api/

响应

{
	"add link": {
		"POST": "/api/add",
		"body": {
			"tinyurl": "bd",
			"fullurl": "https://www.baidu.com",
			"intro": "百度"
		}
	},
	"check unique":{
		"POST": "/api/check",
		"body": {
			"tinyurl": "bd"
		}
	},
	"login": {
		"POST": "/api/login",
		"body": {
			"username": "username",
			"password": "password"
		}
	},
	"update link": {
		"PUT": "/api/update/:id",
		"body": {
			"tinyurl": "bd",
			"fullurl": "https://www.baidu.com",
			"intro": "百度"
		}
	},
	"delete link": {
		"DELETE": "/api/delete/:id"
	},
	"get all links": {
		"GET": "/api/links"
	}
}

2.添加短网址

请求

POST /api/add

参数描述
名字 类型 详细描述
tinyurl string 短网址字符串
fullurl string 完整网址
intro string 网址简介
参数示例
tinyurl: bd
fullurl: https://www.baidu.com
intro: 百度

响应

code 204

3.检查tinyurl是否被使用

请求

POST /api/check

参数描述
名字 类型 详细描述
tinyurl string 短网址字符串
参数示例
tinyurl: bd

响应

if used   unique: false
else
unique: true

4.登录

请求

POST /api/login

参数描述
名字 类型 详细描述
username string 用户名
password string 密码
参数示例
username: username
password: password

响应

code 204

5.修改短网址

请求

PUT /api/update/:id

参数描述
名字 类型 详细描述
tinyurl string 短网址字符串
fullurl string 完整网址
intro string 网址简介
参数示例
tinyurl: bd
fullurl: https://www.baidu.com
intro: 百度

响应

code 204

6.删除短网址

#### 请求 `DELETE /api/delete/:id`

响应

code 204

7.获取所有短网址

请求

GET /api/links

响应

{
  "links": [
    {
      "_id": "589f5f7fe6908f74c73869cf",
      "tinyurl": "bd",
      "fullurl": "https://www.baidu.com",
      "intro": "百度",
      "__v": 0,
      "createAt": "2017-02-11T19:01:19.583Z"
    }
  ]
}

Releases

No releases published

Packages

No packages published