Skip to content

Commit

Permalink
feat: depoly on now serverless function (DIYgod#4554)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx authored Apr 28, 2020
1 parent f5c6d6e commit 7902c54
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ tmp
*.iml
coverage
.env

.now
10 changes: 10 additions & 0 deletions api/now.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path');
const moduleAlias = require('module-alias');
moduleAlias.addAlias('@', path.join(__dirname, '../lib'));
const logger = require('@/utils/logger');
logger.clear();
const s = require('@/app.js').callback();

module.exports = (req, res) => {
s(req, res);
};
4 changes: 4 additions & 0 deletions docs/en/install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ env_variables:
# [END app_yaml]
```

#### Deploy to Vercel(Zeit Now)

Project export a now serverless function with a `now.json` configuration,After installing[Vercel(Zeit Now)](https://vercel.com/docs/now-cli),just run `now` in project directory, RSSHub is on now serverless function.

### Install

Under RSSHub's root directory, execute the following commands to launch RSSHub
Expand Down
4 changes: 4 additions & 0 deletions docs/install/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ env_variables:
# [END app_yaml]
```

#### 部署至 Vercel(Zeit Now)

项目中导出了 now serverless function 并附带 `now.json`相关配置,安装了[Vercel(Zeit Now)](https://vercel.com/docs/now-cli)之后,只需要在项目中运行`now` 即可部署到 Now 的云函数上。

### 安装

在 RSSHub 项目根目录下运行
Expand Down
5 changes: 3 additions & 2 deletions lib/utils/logger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { resolve } = require('path');
const winston = require('winston');
const config = require('@/config').value;

Expand All @@ -10,10 +11,10 @@ const logger = winston.createLogger({
// - Write all logs error (and below) to `error.log`.
//
new winston.transports.File({
filename: 'logs/error.log',
filename: resolve('logs/error.log'),
level: 'error',
}),
new winston.transports.File({ filename: 'logs/combined.log' }),
new winston.transports.File({ filename: resolve('logs/combined.log') }),
],
});

Expand Down
7 changes: 7 additions & 0 deletions now.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": 2,
"routes": [
{ "src": "/api/.*", "dest": "/api/now.js" },
{ "src": "/.*", "dest": "/api/now.js" }
]
}

0 comments on commit 7902c54

Please sign in to comment.