https://github.com/itning/hit-count
仓库访问频次计数徽章
https://github.com/itning/hit-count
hit-counter javascript node
Last synced: 2 months ago
JSON representation
仓库访问频次计数徽章
- Host: GitHub
- URL: https://github.com/itning/hit-count
- Owner: itning
- License: apache-2.0
- Created: 2021-09-16T08:24:43.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-05-28T13:47:56.000Z (about 1 year ago)
- Last Synced: 2025-06-08T12:42:47.021Z (about 1 year ago)
- Topics: hit-counter, javascript, node
- Language: JavaScript
- Homepage:
- Size: 528 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hit count
[](https://github.com/itning/hit-count/stargazers)
[](https://github.com/itning/hit-count/network/members)
[](https://github.com/itning/hit-count/watchers)
[](https://github.com/itning?tab=followers)
[](https://github.com/itning/hit-count/issues)
[](https://github.com/itning/hit-count/blob/master/LICENSE)
[](https://github.com/itning/hit-count/commits)
[](https://github.com/itning/hit-count)
[](https://github.com/itning/hit-count)
## 简介
仓库访问频次计数徽章
效果:

## 如何部署自己的计数器?
### 使用腾讯云函数
使用[腾讯云函数](https://console.cloud.tencent.com/scf/)实现,后端采用redis计数
#### 前提
1. 有能够使云函数访问的Redis服务器,点我查看如何白嫖Redis服务器
2. 腾讯云账号
或者你有服务器那直接部署在服务器上即可,不需要腾讯云函数。
#### 步骤
1. 克隆仓库到本地
`git clone https://github.com/itning/hit-count.git`
2. 进入目录中
`cd ./hit-count/tencent-cloud-serverless-redis/src`
3. 安装依赖
`npm install`
4. 修改redis的访问路径
修改`app.js`文件
```javascript
const redisStore = new redis({
port: 16320, // Redis instance port, redis实例端口
host: "", // Redis instance host, redis实例host
family: 4, // 4 (IPv4) or 6 (IPv6)
password: "", // Redis instance password, redis实例密码
db: 0
});
```
5. 添加访问域名白名单
修改`app.js`文件
```javascript
const authorWhitelist = ["itning"];
```
默认是作者自己,需要修改下
6. 安装腾讯云SLS
`npm install -g serverless`
7. 上传
`serverless deploy --debug`
8. 进入腾讯云控制台查看结果
### 使用服务器
#### 前提
1. 有个服务器
2. 有个公网IP
3. 有个域名(可选)
#### 步骤
1. 克隆仓库到本地
`git clone https://github.com/itning/hit-count.git`
2. 进入目录
`cd ./hit-count/server-redis`
3. 安装依赖
`npm install`
4. 修改redis的访问路径
修改`app.js`文件
```javascript
const redisStore = new redis({
port: 16320, // Redis instance port, redis实例端口
host: "", // Redis instance host, redis实例host
family: 4, // 4 (IPv4) or 6 (IPv6)
password: "", // Redis instance password, redis实例密码
db: 0
});
```
5. 添加访问域名白名单
修改`app.js`文件
```javascript
const authorWhitelist = ["itning"];
```
默认是作者自己,需要修改下
6. 启动
`node app.js`
7. 后台运行(可选)
```shell
# 安装pm2
npm install -g pm2
# 后台运行
pm2 app.js -o ./app.log -e error.log
```
### 使用CloudFlare Workers
1. 克隆仓库到本地
`git clone https://github.com/itning/hit-count.git`
2. 进入目录中
`cd ./hit-count/hit-count-cf-worker`
4. 安装依赖
`npm install`
5. 部署
`npm run deploy`