Skip to content

Commit f3e71ce

Browse files
committed
feat: 使用 TypeScript 重构项目
1 parent 7698766 commit f3e71ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2975
-3368
lines changed

.env.local.example

Lines changed: 0 additions & 7 deletions
This file was deleted.

.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ yarn-error.log*
2626
.pnpm-debug.log*
2727

2828
# local env files
29-
.env.local
30-
.env.development.local
31-
.env.test.local
32-
.env.production.local
29+
.env*.local
3330

3431
# vercel
3532
.vercel
3633

37-
# yarn
38-
yarn.lock
39-
/.idea
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
next.config.js
38+
39+
# JetBrains
40+
.idea

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# platform
2+
.vercel
3+
4+
# Ignore artifacts:
5+
node_modules
6+
7+
pnpm-lock.yaml

.prettierrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"semi": false
3+
}

README.md

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
1-
This is a xmlrpc metaweblog api server based on [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2-
3-
## Endpoint
4-
5-
[/api/xmlrpc](https://api.terwer.space/api/xmlrpc)
6-
7-
[/api/translate?q=](https://api.terwer.space/api/translate?q=)
8-
9-
[/api/jieba?q=](https://api.terwer.space/api/jieba?q=)
10-
11-
## 最近更新
12-
13-
### 2022-07-27
14-
15-
1、新增中文分词服务
16-
17-
### 2022-07-24
18-
19-
1、新增Google翻译服务
20-
21-
### 2022-07-09
22-
23-
1、修复标签无法发送问题
24-
25-
2、修复文章ID问题,conf的返回值格式id_version,需要把ID返回给api
26-
27-
3、更新文章时,父页面、标签改为可选,默认不更新父页面。
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
282

293
## Getting Started
304

@@ -38,12 +12,14 @@ yarn dev
3812

3913
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
4014

41-
You can start editing the page by modifying `pages/index.jsx`. The page auto-updates as you edit the file.
15+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
4216

43-
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
4418

4519
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
4620

21+
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
22+
4723
## Learn More
4824

4925
To learn more about Next.js, take a look at the following resources:

lib/init-middleware.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

next.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

next.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import path from "path"
2+
import { NextConfig } from "next"
3+
4+
/**
5+
* 获取模块路径
6+
* @param m 模块名称
7+
*/
8+
function moduleDir(m: string) {
9+
return path.dirname(require.resolve(`${m}/package.json`))
10+
}
11+
12+
console.log("react path=>", moduleDir("react"))
13+
14+
/**
15+
* @type {import('next').NextConfig}
16+
* @see https://nextjs.org/docs/api-reference/next.config.js/
17+
**/
18+
const nextConfig: NextConfig = {
19+
reactStrictMode: true,
20+
}
21+
22+
module.exports = nextConfig

package.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
{
2+
"name": "node-metaweblog-api-adaptor",
3+
"version": "0.1.0",
24
"private": true,
35
"scripts": {
4-
"dev": "next dev",
5-
"build": "next build",
6+
"predev": "pnpm build:config",
7+
"dev": "pnpm predev && next dev",
8+
"prebuild": "yarn build:config",
9+
"build": "pnpm prebuild && next build",
10+
"build:config": "esbuild next.config.ts --bundle --outfile=next.config.js --platform=node --external:pnpapi --target=es2020 --minify",
611
"start": "next start",
712
"lint": "next lint"
813
},
914
"dependencies": {
10-
"base-64": "^1.0.0",
11-
"cors": "^2.8.5",
12-
"metaweblog-api": "^1.2.0",
13-
"next": "12.1.4",
14-
"nodejieba": "^2.6.0",
15-
"react": "18.0.0",
16-
"react-dom": "18.0.0",
17-
"xml2json": "^0.12.0",
18-
"xmlrpc": "^1.3.2"
15+
"next": "13.1.1",
16+
"react": "18.2.0",
17+
"react-dom": "18.2.0",
18+
"typescript": "4.9.4"
1919
},
2020
"devDependencies": {
21-
"eslint": "8.12.0",
22-
"eslint-config-next": "12.1.4"
21+
"@next/font": "13.1.1",
22+
"@types/node": "18.11.18",
23+
"@types/react": "18.0.26",
24+
"@types/react-dom": "18.0.10",
25+
"esbuild": "^0.16.16",
26+
"eslint": "8.31.0",
27+
"eslint-config-next": "13.1.1",
28+
"prettier": "^2.8.2"
2329
}
2430
}

0 commit comments

Comments
 (0)