-
-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(platform-fastify): add Fastify platform #2925
base: production
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test | ||
coverage | ||
tsconfig.json | ||
tsconfig.*.json | ||
__mock__ | ||
*.spec.js | ||
*.tsbuildinfo | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"sourceMaps": false, | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"decorators": true, | ||
"dynamicImport": true | ||
}, | ||
"target": "es2022", | ||
"externalHelpers": true, | ||
"keepClassNames": true, | ||
"transform": { | ||
"useDefineForClassFields": false, | ||
"legacyDecorator": true, | ||
"decoratorMetadata": true | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,121 @@ | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
"name": "@tsed/platform-fastify", | ||||||||||||||||||||||
"type": "module", | ||||||||||||||||||||||
"version": "8.2.0", | ||||||||||||||||||||||
"description": "Fastify package for Ts.ED framework", | ||||||||||||||||||||||
"source": "./src/index.ts", | ||||||||||||||||||||||
"main": "./lib/esm/index.js", | ||||||||||||||||||||||
"module": "./lib/esm/index.js", | ||||||||||||||||||||||
"typings": "./lib/types/index.d.ts", | ||||||||||||||||||||||
"exports": { | ||||||||||||||||||||||
".": { | ||||||||||||||||||||||
"@tsed/source": "./src/index.ts", | ||||||||||||||||||||||
"types": "./lib/types/index.d.ts", | ||||||||||||||||||||||
"import": "./lib/esm/index.js", | ||||||||||||||||||||||
"default": "./lib/esm/index.js" | ||||||||||||||||||||||
} | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"scripts": { | ||||||||||||||||||||||
"build": "yarn barrels && yarn build:ts", | ||||||||||||||||||||||
"barrels": "barrels", | ||||||||||||||||||||||
"start": "node --import @swc-node/register/esm-register test/app/index.ts", | ||||||||||||||||||||||
"test": "vitest run -u", | ||||||||||||||||||||||
"build:ts": "tsc --build tsconfig.json", | ||||||||||||||||||||||
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"keywords": [ | ||||||||||||||||||||||
"Koa", | ||||||||||||||||||||||
"TypeScript", | ||||||||||||||||||||||
Comment on lines
+27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Remove duplicate keyword "TypeScript" The keywords array contains both "TypeScript" and "typescript" (case variants). "keywords": [
"Koa",
"TypeScript",
- "typescript",
"Decorator",
|
||||||||||||||||||||||
"typescript", | ||||||||||||||||||||||
"Decorator", | ||||||||||||||||||||||
"decorators", | ||||||||||||||||||||||
"decorator", | ||||||||||||||||||||||
"fastify", | ||||||||||||||||||||||
"Controller", | ||||||||||||||||||||||
"Inject", | ||||||||||||||||||||||
"ioc", | ||||||||||||||||||||||
"di", | ||||||||||||||||||||||
"mvc", | ||||||||||||||||||||||
"swagger", | ||||||||||||||||||||||
"swagger ui", | ||||||||||||||||||||||
"ES2015", | ||||||||||||||||||||||
"ES6", | ||||||||||||||||||||||
"server", | ||||||||||||||||||||||
"rest", | ||||||||||||||||||||||
"api", | ||||||||||||||||||||||
"validation" | ||||||||||||||||||||||
], | ||||||||||||||||||||||
"author": { | ||||||||||||||||||||||
"name": "Romain Lenzotti" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"license": "MIT", | ||||||||||||||||||||||
"bugs": { | ||||||||||||||||||||||
"url": "https://github.com/tsedio/tsed/issues" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"homepage": "http://tsed.dev/", | ||||||||||||||||||||||
"repository": { | ||||||||||||||||||||||
"type": "git", | ||||||||||||||||||||||
"url": "git+https://github.com/tsedio/tsed.git" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"dependencies": { | ||||||||||||||||||||||
"@fastify/middie": ">=9.0.2", | ||||||||||||||||||||||
"content-disposition": ">=0.5.4", | ||||||||||||||||||||||
"tslib": "2.6.1" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
Comment on lines
+60
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Pin dependency versions for better stability Using "dependencies": {
- "@fastify/middie": ">=9.0.2",
+ "@fastify/middie": "^9.0.2",
- "content-disposition": ">=0.5.4",
+ "content-disposition": "^0.5.4",
"tslib": "2.6.1" 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
"devDependencies": { | ||||||||||||||||||||||
"@fastify/accepts": "5.0.2", | ||||||||||||||||||||||
"@fastify/cookie": "11.0.1", | ||||||||||||||||||||||
"@fastify/formbody": "8.0.1", | ||||||||||||||||||||||
"@fastify/session": "11.0.1", | ||||||||||||||||||||||
"@tsed/barrels": "workspace:*", | ||||||||||||||||||||||
"@tsed/core": "workspace:*", | ||||||||||||||||||||||
"@tsed/di": "workspace:*", | ||||||||||||||||||||||
"@tsed/platform-http": "workspace:*", | ||||||||||||||||||||||
"@tsed/platform-test-sdk": "workspace:*", | ||||||||||||||||||||||
"@types/content-disposition": "^0.5.4", | ||||||||||||||||||||||
"cross-env": "7.0.3", | ||||||||||||||||||||||
"fastify": "5.1.0", | ||||||||||||||||||||||
"fastify-raw-body": "5.0.0", | ||||||||||||||||||||||
"ts-node": "10.9.2" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"peerDependencies": { | ||||||||||||||||||||||
"@fastify/accepts": ">=4.3.0", | ||||||||||||||||||||||
"@fastify/cookie": ">=9.3.1", | ||||||||||||||||||||||
"@fastify/formbody": ">=7.4.0", | ||||||||||||||||||||||
"@tsed/core": ">=8.0.0", | ||||||||||||||||||||||
"@tsed/di": ">=8.0.0", | ||||||||||||||||||||||
"@tsed/json-mapper": ">=8.0.0", | ||||||||||||||||||||||
"@tsed/logger": ">=7.0.0", | ||||||||||||||||||||||
"@tsed/openspec": ">=8.0.0", | ||||||||||||||||||||||
"@tsed/platform-http": ">=8.0.0", | ||||||||||||||||||||||
"@tsed/schema": ">=8.0.0", | ||||||||||||||||||||||
"fastify": ">=5.1.0", | ||||||||||||||||||||||
"fastify-raw-body": ">=5.0.0" | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"peerDependenciesMeta": { | ||||||||||||||||||||||
"@tsed/common": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"@tsed/core": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"@tsed/di": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"@tsed/json-mapper": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"@tsed/logger": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"@tsed/openspec": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"@tsed/schema": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
"fastify": { | ||||||||||||||||||||||
"optional": false | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,67 @@ | ||||||
<p style="text-align: center" align="center"> | ||||||
<a href="https://tsed.io" target="_blank"><img src="https://tsed.io/tsed-og.png" width="200" alt="Ts.ED logo"/></a> | ||||||
</p> | ||||||
|
||||||
<div align="center"> | ||||||
<h1>Platform Fastify</h1> | ||||||
|
||||||
[![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) | ||||||
[![PR Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/tsedio/tsed/blob/master/CONTRIBUTING.md) | ||||||
[![Coverage Status](https://coveralls.io/repos/github/tsedio/tsed/badge.svg?branch=production)](https://coveralls.io/github/tsedio/tsed?branch=production) | ||||||
[![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon) | ||||||
[![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) | ||||||
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) | ||||||
[![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita) | ||||||
[![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed) | ||||||
|
||||||
</div> | ||||||
|
||||||
<div align="center"> | ||||||
<a href="https://tsed.io/">Website</a> | ||||||
<span> • </span> | ||||||
<a href="https://tsed.io/getting-started/">Getting started</a> | ||||||
<span> • </span> | ||||||
<a href="https://api.tsed.io/rest/slack/tsedio/tsed">Slack</a> | ||||||
<span> • </span> | ||||||
<a href="https://twitter.com/TsED_io">Twitter</a> | ||||||
</div> | ||||||
|
||||||
<hr /> | ||||||
|
||||||
A package of Ts.ED framework. See website: https://tsed.io/getting-started/ | ||||||
|
||||||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add configuration examples section Add a new section with:
Example content to add: ## Configuration
```typescript
import {Configuration} from "@tsed/common";
import "@tsed/platform-fastify"; // import fastify platform
@Configuration({
platform: "fastify",
fastify: {
// your fastify options
}
})
export class Server {
} 🧰 Tools🪛 Markdownlint (0.35.0)31-31: null (MD034, no-bare-urls) |
||||||
## Installation | ||||||
|
||||||
Run npm command (or yarn): | ||||||
|
||||||
```bash | ||||||
npm install --save @tsed/platform-fastify fastify | ||||||
``` | ||||||
Comment on lines
+37
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Enhance installation instructions The installation section could be more comprehensive by including peer dependencies and configuration examples. Consider adding:
|
||||||
|
||||||
## Contributors | ||||||
|
||||||
Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html) | ||||||
|
||||||
<a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a> | ||||||
|
||||||
## Backers | ||||||
|
||||||
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)] | ||||||
|
||||||
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a> | ||||||
|
||||||
## Sponsors | ||||||
|
||||||
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)] | ||||||
|
||||||
## License | ||||||
|
||||||
The MIT License (MIT) | ||||||
|
||||||
Copyright (c) 2016 - 2018 Romain Lenzotti | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Update copyright year range The copyright year range (2016 - 2018) appears outdated for this new package. - Copyright (c) 2016 - 2018 Romain Lenzotti
+ Copyright (c) 2016 - 2024 Romain Lenzotti 📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[typographical] ~61-~61: If you want to indicate numerical ranges or time ranges, consider using an en dash. (DASH_RULE) |
||||||
|
||||||
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: | ||||||
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||||||
|
||||||
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 number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||||||||||||||||||||
import {PlatformBuilder} from "@tsed/platform-http"; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import {PlatformFastify} from "./PlatformFastify.js"; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
class Server {} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
describe("PlatformFastify", () => { | ||||||||||||||||||||||||
describe("create()", () => { | ||||||||||||||||||||||||
beforeEach(() => { | ||||||||||||||||||||||||
vi.spyOn(PlatformBuilder, "create").mockReturnValue({}); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
afterEach(() => vi.resetAllMocks()); | ||||||||||||||||||||||||
it("should create platform", () => { | ||||||||||||||||||||||||
PlatformFastify.create(Server, {}); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
expect(PlatformBuilder.create).toHaveBeenCalledWith(Server, { | ||||||||||||||||||||||||
adapter: PlatformFastify | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
Comment on lines
+13
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Enhance test coverage with additional assertions and scenarios. While the basic functionality is tested, consider adding:
|
||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
describe("bootstrap()", () => { | ||||||||||||||||||||||||
beforeEach(() => { | ||||||||||||||||||||||||
vi.spyOn(PlatformBuilder, "bootstrap").mockReturnValue({}); | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
afterEach(() => vi.resetAllMocks()); | ||||||||||||||||||||||||
it("should create platform", async () => { | ||||||||||||||||||||||||
await PlatformFastify.bootstrap(Server, {}); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
expect(PlatformBuilder.bootstrap).toHaveBeenCalledWith(Server, { | ||||||||||||||||||||||||
adapter: PlatformFastify | ||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
Comment on lines
+27
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Add assertions for the returned platform instance The test only verifies that bootstrap was called but doesn't assert anything about the returned platform instance. - await PlatformFastify.bootstrap(Server, {});
+ const platform = await PlatformFastify.bootstrap(Server, {});
expect(PlatformBuilder.bootstrap).toHaveBeenCalledWith(Server, {
adapter: PlatformFastify
});
+ expect(platform).toBeDefined(); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Build & Release[warning] Warning: Statics middleware is not implemented yet |
||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
Comment on lines
+26
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Improve test description and add error scenarios. The test description "should create platform" is too generic. Consider:
|
||||||||||||||||||||||||
}); | ||||||||||||||||||||||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Based on the files found in the package and parent directories, I can now generate the final response:
Add source files and IDE patterns to .npmignore
The current .npmignore should be extended to include:
Add these patterns:
src/
.idea
.vscode
*.ts
!*.d.ts
test/app/views/
test/app/public/
vitest.config.mts
🔗 Analysis chain
Verify completeness of ignore patterns
Let's check if there are any additional file types in the codebase that should be ignored.
Let me try another search strategy to find potential files that should be ignored.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 351
Script:
Length of output: 1818