# blog-server **Repository Path**: SpectreAlan/blog-server ## Basic Information - **Project Name**: blog-server - **Description**: 基于Egg.js搭建的博客中台,提供博客系统的API - **Primary Language**: JavaScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-12-21 - **Last Updated**: 2022-02-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
在新窗口里面,note随意填写,然后勾选如图所示的绿色小钩,然后点击最下方的创建按钮,创建成功以后复制下生成的tokens备用
### 3.百度push
找到config.baiduPush字段配置接口调用地址,登录百度站长管理平台,找到如下接口地址
## 4.部署及后续操作
命令行切换到项目根目录
```bash
# 启动服务
yarn start
# 停止服务
yarn start
# 重启服务
yarn stop
```
# 配置文件说明
```javascript
module.exports = appInfo => {
const config = exports = {};
// 权限验证和错误处理的中间件
config.middleware = [ 'authority', 'errorHandler' ];
// 参数校验
config.validate = {
convert: true,
widelyUndefined: true,
};
const userConfig = {
myAppName: 'blog',
};
// 跨域访问权限
config.security = {
csrf: {
enable: false,
},
domainWhiteList: [ '*' ],
};
// 跨域访问权限
config.cors = {
origin: '*',
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
};
// mysql配置
config.mysql = {
client: {
host: '127.0.0.1', // 主机地址
port: '3306', // 端口号
user: 'root', // 连接mysql的用户名
password: '', // 连接mysql的密码
database: 'blog', // 需要操作的库
},
app: true,
agent: false,
};
// session相关配置
config.session = {
key: 'SESSION_ID',
maxAge: 1000 * 60 * 30, // 过期时间
httpOnly: true,
encrypt: true,
renew: true, // 自动刷新
};
// 文件上传配置
config.upLoad = {
multipart: true,
formidable: {
maxFileSize: 200 * 1024 * 1024, // 设置上传文件大小最大限制,默认2M
},
};
// 文件上传配置
config.multipart = {
mode: 'file',
};
config.imageType = [ 'png', 'jpg', 'jpeg', 'gif' ];
// github图床配置
config.github = {
reqBaseUrl: 'http://api.github.com/repos/用户名/仓库/contents',
imgBaseUrl: 'https://raw.githubusercontent.com/用户名/仓库/master/',
token: '', // Personal access tokens
};
// 阿里云oss配置
config.aliyun = {
region: '', // 格式: oss-cn-hangzhou、oss-cn-beijing
accessKeyId: '',
accessKeySecret: '',
bucket: '', // Bucket名称
};
// bing图片请求地址
config.bing = 'https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1';
// 一言请求地址
config.hitokoto = 'https://v1.hitokoto.cn';
// 百度推送api
config.baiduPush = '';
config.rundir = process.cwd() + '/run';// 配置执行时临时文件的路径
config.logger = {
dir: path.join(process.cwd(), 'logs'), // 配置普通日志文件地址
};
config.customLogger = {
scheduleLogger: {
file: path.join(process.cwd(), 'logs', 'egg-schedule.log'), // 配置定时任务日志的地址
},
};
// 绑定静态目录
config.static = {
dir: process.cwd() + '/public',
};
return {
...config,
...userConfig,
};
};
```