Skip to content

Commit 786b751

Browse files
committed
feat(platform-fastify): add Fastify platform
1 parent ad41468 commit 786b751

28 files changed

+1766
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test
2+
coverage
3+
tsconfig.json
4+
tsconfig.*.json
5+
__mock__
6+
*.spec.js
7+
*.tsbuildinfo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
"name": "@tsed/platform-fastify",
3+
"type": "module",
4+
"version": "8.2.0",
5+
"description": "Fastify package for Ts.ED framework",
6+
"source": "./src/index.ts",
7+
"main": "./lib/esm/index.js",
8+
"module": "./lib/esm/index.js",
9+
"typings": "./lib/types/index.d.ts",
10+
"exports": {
11+
".": {
12+
"@tsed/source": "./src/index.ts",
13+
"types": "./lib/types/index.d.ts",
14+
"import": "./lib/esm/index.js",
15+
"default": "./lib/esm/index.js"
16+
}
17+
},
18+
"scripts": {
19+
"build": "yarn barrels && yarn build:ts",
20+
"barrels": "barrels",
21+
"start": "ts-node test/app/index.ts",
22+
"test": "vitest run -u",
23+
"build:ts": "tsc --build tsconfig.json",
24+
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
25+
},
26+
"keywords": [
27+
"Koa",
28+
"TypeScript",
29+
"typescript",
30+
"Decorator",
31+
"decorators",
32+
"decorator",
33+
"fastify",
34+
"Controller",
35+
"Inject",
36+
"ioc",
37+
"di",
38+
"mvc",
39+
"swagger",
40+
"swagger ui",
41+
"ES2015",
42+
"ES6",
43+
"server",
44+
"rest",
45+
"api",
46+
"validation"
47+
],
48+
"author": {
49+
"name": "Romain Lenzotti"
50+
},
51+
"license": "MIT",
52+
"bugs": {
53+
"url": "https://github.com/tsedio/tsed/issues"
54+
},
55+
"homepage": "http://tsed.dev/",
56+
"repository": {
57+
"type": "git",
58+
"url": "git+https://github.com/tsedio/tsed.git"
59+
},
60+
"dependencies": {
61+
"@fastify/middie": ">=9.0.2",
62+
"content-disposition": ">=0.5.4",
63+
"tslib": "2.6.1"
64+
},
65+
"devDependencies": {
66+
"@fastify/accepts": "5.0.2",
67+
"@fastify/cookie": "11.0.1",
68+
"@fastify/formbody": "8.0.1",
69+
"@fastify/session": "11.0.1",
70+
"@tsed/barrels": "workspace:*",
71+
"@tsed/core": "workspace:*",
72+
"@tsed/di": "workspace:*",
73+
"@tsed/platform-http": "workspace:*",
74+
"@tsed/platform-test-sdk": "workspace:*",
75+
"@types/content-disposition": "^0.5.4",
76+
"cross-env": "7.0.3",
77+
"fastify": "5.1.0",
78+
"fastify-raw-body": "5.0.0",
79+
"ts-node": "10.9.2"
80+
},
81+
"peerDependencies": {
82+
"@fastify/accepts": ">=4.3.0",
83+
"@fastify/cookie": ">=9.3.1",
84+
"@fastify/formbody": ">=7.4.0",
85+
"@fastify/session": ">=10.7.0",
86+
"@tsed/core": ">=8.0.0",
87+
"@tsed/di": ">=8.0.0",
88+
"@tsed/json-mapper": ">=8.0.0",
89+
"@tsed/logger": ">=7.0.0",
90+
"@tsed/openspec": ">=8.0.0",
91+
"@tsed/platform-http": ">=8.0.0",
92+
"@tsed/schema": ">=8.0.0",
93+
"fastify": ">=5.1.0",
94+
"fastify-raw-body": ">=5.0.0"
95+
},
96+
"peerDependenciesMeta": {
97+
"@tsed/common": {
98+
"optional": false
99+
},
100+
"@tsed/core": {
101+
"optional": false
102+
},
103+
"@tsed/di": {
104+
"optional": false
105+
},
106+
"@tsed/json-mapper": {
107+
"optional": false
108+
},
109+
"@tsed/logger": {
110+
"optional": false
111+
},
112+
"@tsed/openspec": {
113+
"optional": false
114+
},
115+
"@tsed/schema": {
116+
"optional": false
117+
},
118+
"fastify": {
119+
"optional": false
120+
}
121+
}
122+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<p style="text-align: center" align="center">
2+
<a href="https://tsed.io" target="_blank"><img src="https://tsed.io/tsed-og.png" width="200" alt="Ts.ED logo"/></a>
3+
</p>
4+
5+
<div align="center">
6+
<h1>Platform Fastify</h1>
7+
8+
[![Build & Release](https://github.com/tsedio/tsed/workflows/Build%20&%20Release/badge.svg)](https://github.com/tsedio/tsed/actions?query=workflow%3A%22Build+%26+Release%22)
9+
[![PR Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/tsedio/tsed/blob/master/CONTRIBUTING.md)
10+
[![Coverage Status](https://coveralls.io/repos/github/tsedio/tsed/badge.svg?branch=production)](https://coveralls.io/github/tsedio/tsed?branch=production)
11+
[![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
12+
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
13+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14+
[![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita)
15+
[![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed)
16+
17+
</div>
18+
19+
<div align="center">
20+
<a href="https://tsed.io/">Website</a>
21+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
22+
<a href="https://tsed.io/getting-started/">Getting started</a>
23+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
24+
<a href="https://api.tsed.io/rest/slack/tsedio/tsed">Slack</a>
25+
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
26+
<a href="https://twitter.com/TsED_io">Twitter</a>
27+
</div>
28+
29+
<hr />
30+
31+
A package of Ts.ED framework. See website: https://tsed.io/getting-started/
32+
33+
## Installation
34+
35+
Run npm command (or yarn):
36+
37+
```bash
38+
npm install --save @tsed/platform-fastify fastify
39+
```
40+
41+
## Contributors
42+
43+
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
44+
45+
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
46+
47+
## Backers
48+
49+
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
50+
51+
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
52+
53+
## Sponsors
54+
55+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
56+
57+
## License
58+
59+
The MIT License (MIT)
60+
61+
Copyright (c) 2016 - 2018 Romain Lenzotti
62+
63+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
64+
65+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66+
67+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {PlatformBuilder} from "@tsed/common";
2+
3+
import {PlatformFastify} from "./PlatformFastify";
4+
5+
class Server {}
6+
7+
describe("PlatformFastify", () => {
8+
describe("create()", () => {
9+
beforeEach(() => {
10+
jest.spyOn(PlatformBuilder, "create").mockReturnValue({});
11+
});
12+
afterEach(() => jest.resetAllMocks());
13+
it("should create platform", () => {
14+
PlatformFastify.create(Server, {});
15+
16+
expect(PlatformBuilder.create).toHaveBeenCalledWith(Server, {
17+
adapter: PlatformFastify
18+
});
19+
});
20+
});
21+
describe("bootstrap()", () => {
22+
beforeEach(() => {
23+
jest.spyOn(PlatformBuilder, "bootstrap").mockReturnValue({});
24+
});
25+
afterEach(() => jest.resetAllMocks());
26+
it("should create platform", async () => {
27+
await PlatformFastify.bootstrap(Server, {});
28+
29+
expect(PlatformBuilder.bootstrap).toHaveBeenCalledWith(Server, {
30+
adapter: PlatformFastify
31+
});
32+
});
33+
});
34+
});

0 commit comments

Comments
 (0)