@hexlet/frontend-blog-server 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/package.json +14 -4
package/README.md
CHANGED
|
@@ -21,7 +21,17 @@ npx frontend-blog-server contract # openapi.yaml и main.tsp в ./contr
|
|
|
21
21
|
npx frontend-blog-server contract api # в указанный каталог
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
`openapi.yaml` описывает все эндпоинты, тела запросов и ответов и коды ошибок.
|
|
24
|
+
`openapi.yaml` описывает все эндпоинты, тела запросов и ответов и коды ошибок.
|
|
25
|
+
|
|
26
|
+
## Типы
|
|
27
|
+
|
|
28
|
+
Пакет отдаёт типы, сгенерированные из `openapi.yaml` утилитой `openapi-typescript`. Они подходят для `openapi-fetch` и для своей обёртки над `fetch`.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import type { components, paths } from "@hexlet/frontend-blog-server/schema";
|
|
32
|
+
|
|
33
|
+
type Article = components["schemas"]["Article"];
|
|
34
|
+
```
|
|
25
35
|
|
|
26
36
|
## Сид
|
|
27
37
|
|
|
@@ -44,6 +54,6 @@ npx frontend-blog-server contract api # в указанный катало
|
|
|
44
54
|
```bash
|
|
45
55
|
npm ci
|
|
46
56
|
npm test # тесты API
|
|
47
|
-
npm run gen:types # src/generated/api.ts из contract/openapi.yaml
|
|
57
|
+
npm run gen:types # src/generated/api.ts из contract/openapi.yaml, генератор идёт через npx с TypeScript 5
|
|
48
58
|
cd contract && npm ci && npm run compile # openapi.yaml из main.tsp
|
|
49
59
|
```
|
package/package.json
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexlet/frontend-blog-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Hexlet-provided backend for the blog project. Implements the contract/ OpenAPI in-memory and serves a built SPA.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/app.js",
|
|
7
7
|
"types": "dist/src/app.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/src/app.d.ts",
|
|
11
|
+
"default": "./dist/src/app.js"
|
|
12
|
+
},
|
|
13
|
+
"./schema": {
|
|
14
|
+
"types": "./dist/src/generated/api.d.ts",
|
|
15
|
+
"default": "./dist/src/generated/api.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
8
19
|
"bin": {
|
|
9
20
|
"frontend-blog-server": "dist/bin/cli.js"
|
|
10
21
|
},
|
|
@@ -22,7 +33,7 @@
|
|
|
22
33
|
},
|
|
23
34
|
"scripts": {
|
|
24
35
|
"build": "tsc -p tsconfig.json",
|
|
25
|
-
"gen:types": "openapi-typescript contract/openapi.yaml -o src/generated/api.ts && oxfmt src/generated/api.ts",
|
|
36
|
+
"gen:types": "npx -y -p typescript@5 -p openapi-typescript@7.13.0 openapi-typescript contract/openapi.yaml -o src/generated/api.ts && oxfmt src/generated/api.ts",
|
|
26
37
|
"dev": "fastify start -w -l info -P -a 0.0.0.0 -p 8080 -i tsx src/app.ts",
|
|
27
38
|
"start": "fastify start -l info -a 0.0.0.0 -p 8080 dist/src/app.js",
|
|
28
39
|
"test": "vitest run",
|
|
@@ -41,12 +52,11 @@
|
|
|
41
52
|
},
|
|
42
53
|
"devDependencies": {
|
|
43
54
|
"@types/node": "^26.6.5",
|
|
44
|
-
"openapi-typescript": "^7.13.0",
|
|
45
55
|
"oxfmt": "^0.75.0",
|
|
46
56
|
"oxlint": "^1.90.0",
|
|
47
57
|
"release-it": "^21.1.1",
|
|
48
58
|
"tsx": "^4.23.15",
|
|
49
|
-
"typescript": "^
|
|
59
|
+
"typescript": "^7.0.2",
|
|
50
60
|
"vitest": "^5.0.5"
|
|
51
61
|
}
|
|
52
62
|
}
|