Skip to content

Commit

Permalink
style: fmt code
Browse files Browse the repository at this point in the history
  • Loading branch information
beetcb committed May 31, 2021
1 parent 560375d commit 471f1dd
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 205 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,17 @@
vercel --prod
```

到此部署完成,访问地址可以在命令行或 vercel 官网看到。需要使用自定义域名,请参考 [custom-domains](https://vercel.com/docs/custom-domains#)
到此部署完成,访问地址可以在命令行或 vercel 官网看到。需要使用自定义域名,请参考 [custom-domains][vercel-custom-domains]

3. 访问地址示例:https://your.app/?path=/path/to/file.md

4. (可选)配置 Vercel 持续部署,更新功能更便捷:`fork` 本项目,在 Vercel 导入新的 GitHub 项目:

![vercel-import][vercel-import]

`ROOT DIRECTORY``platforms/vercel/sosf`,Environmental Variables 填入之前生成的 `.env` 中的键值对 (也就是说你需要手动添加多次,目前还没有找到好的解决方案,欢迎开 Issue 讨论解法)

![vercel-import-success][vercel-import-success]

### 部署配置

Expand All @@ -232,13 +239,9 @@ access_key = 前端界面鉴权密钥,持有此密钥才能访问文件夹内
## 鸣谢

- [Tencent CloudBase][tcb-thanks]
- [LeanCloud][leancloud-thanks]
- [Vercel][vercel-thanks]

[tcb-thanks]: https://github.com/TencentCloudBase
[leancloud-notice]: https://leancloud.cn/docs/leanengine_plan.html#hash643734278
[leancloud-thanks]: https://github.com/leancloud
[leancloud-price]: https://www.leancloud.cn/pricing/
[vercel-thanks]: https://github.com/vercel/vercel
[vercel-func]: https://vercel.com/docs/serverless-functions/introduction
[license]: https://github.com/beetcb/sosf/blob/tcb-scf/LICENSE
Expand All @@ -251,3 +254,6 @@ access_key = 前端界面鉴权密钥,持有此密钥才能访问文件夹内
[tcb-btn-link]: https://console.cloud.tencent.com/tcb/env/index?action=CreateAndDeployCloudBaseProject&appUrl=https%3A%2F%2Fgithub.com%2Fbeetcb%2Fsosf&branch=main
[fair-use]: https://vercel.com/docs/platform/fair-use-policy
[github-actions-secret]: https://i.imgur.com/sY9Vthc.png
[vercel-import]: https://i.imgur.com/LpozMqw.png
[vercel-custom-domains]: https://vercel.com/docs/custom-domains#
[vercel-import-success]: https://i.imgur.com/K1WbX6Q.png
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"inquirer": "^8.0.0",
"node-fetch": "^2.6.1"
}
}
}
12 changes: 5 additions & 7 deletions platforms/cloudbase/sosf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ async function handler({ path, queryStringParameters, headers }) {

if (isReqFolder && type !== 'file') {
// Render folder
const isReturnJson =
type === 'json' ||
(headers['content-type'] && headers['content-type'].includes('json'))
const isReturnJson = type === 'json'
|| (headers['content-type'] && headers['content-type'].includes('json'))

// Render html first
if (!isReturnJson) {
Expand Down Expand Up @@ -54,12 +53,11 @@ async function handler({ path, queryStringParameters, headers }) {
const itemTable = data.value.reduce((arr, ele) => {
arr.push({
name: `${ele.name}${ele.file ? '' : '/'}`,
params:
'?' +
new URLSearchParams(
params: '?'
+ new URLSearchParams(
`${ele.id ? `&id=${ele.id}` : ''}${
key && !ele.file ? `&key=${key}` : ''
}${ele.file ? '&type=file' : ''}`
}${ele.file ? '&type=file' : ''}`,
).toString(),
})
return arr
Expand Down
6 changes: 3 additions & 3 deletions platforms/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function initDocument() {

// render table
const { id, key, type } = Object.fromEntries(
new URL(location.href).searchParams
new URL(location.href).searchParams,
)
const isNoParams = !(id || key || type)
new gridjs.Grid({
Expand All @@ -41,7 +41,7 @@ function initDocument() {
'py-2 mb-4 px-4 border rounded-md text-white bg-blue-600',
href: row.cells[1].data,
},
'Link'
'Link',
)
},
},
Expand All @@ -51,7 +51,7 @@ function initDocument() {
url: encodeURI(
`${location.href}${
isNoParams ? `?type=json${key ? `&key=${key}` : ''}` : '&type=json'
}`
}`,
),
then: (data) =>
data.map(({ name, params }) => {
Expand Down
14 changes: 6 additions & 8 deletions platforms/vercel/sosf/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getToken, getItem, listChildren } from '@beetcb/sor'
import { getItem, getToken, listChildren } from '@beetcb/sor'

export default async function handler({
path,
Expand All @@ -23,9 +23,8 @@ export default async function handler({

if (isReqFolder && type !== 'file') {
// Render folder
const isReturnJson =
type === 'json' ||
(headers['content-type'] && headers['content-type'].includes('json'))
const isReturnJson = type === 'json'
|| (headers['content-type'] && headers['content-type'].includes('json'))

// Render html first
if (!isReturnJson) {
Expand Down Expand Up @@ -60,12 +59,11 @@ export default async function handler({
const itemTable = data.value.reduce((arr, ele) => {
arr.push({
name: `${ele.name}${ele.file ? '' : '/'}`,
params:
'?' +
new URLSearchParams(
params: '?'
+ new URLSearchParams(
`${ele.id ? `&id=${ele.id}` : ''}${
key && !ele.file ? `&key=${key}` : ''
}${ele.file ? '&type=file' : ''}`
}${ele.file ? '&type=file' : ''}`,
).toString(),
})
return arr
Expand Down
2 changes: 1 addition & 1 deletion platforms/vercel/sosf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"@beetcb/sor": "^1.0.3"
},
"devDependencies": {}
}
}
12 changes: 7 additions & 5 deletions sor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Plz make sure the following environment variables key is set:

```ts
export interface GraphAuthEnv {
[(key in 'client_id') |
'client_secret' |
'refresh_token' |
'redirect_uri' |
'auth_endpoint']: string
[
(key in 'client_id')
| 'client_secret'
| 'refresh_token'
| 'redirect_uri'
| 'auth_endpoint'
]: string
}
```
Loading

1 comment on commit 471f1dd

@vercel
Copy link

@vercel vercel bot commented on 471f1dd May 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.