Gathering detailed insights and metrics for @tsed/platform-express
Gathering detailed insights and metrics for @tsed/platform-express
Gathering detailed insights and metrics for @tsed/platform-express
Gathering detailed insights and metrics for @tsed/platform-express
📐 Ts.ED is a Node.js and TypeScript framework on top of Express to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone. ⭐️ Star to support our work!
npm install @tsed/platform-express
55.5
Supply Chain
83.1
Quality
93.4
Maintenance
100
Vulnerability
98.2
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2,864 Stars
5,359 Commits
284 Forks
43 Watching
53 Branches
139 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
TypeScript (97.47%)
JavaScript (1.63%)
EJS (0.75%)
HTML (0.1%)
Shell (0.06%)
Cumulative downloads
Total Downloads
Last day
-1.8%
2,043
Compared to previous day
Last week
-23.2%
12,139
Compared to previous week
Last month
15.2%
59,339
Compared to previous month
Last year
36.7%
708,859
Compared to previous year
12
24
A Node.js and TypeScript Framework on top of Express. It provides a lot of decorators and guidelines to write your code.
Ts.ED is a Node.js and TypeScript Framework on top of Express/Koa.js. Ts.ED is a framework on top of Express/Koa to write your application with TypeScript (or ES6). It provides a lot of decorators and guideline to make your code more readable and less error-prone.
See our getting started here to create new Ts.ED project or use our CLI
Here an example to create a Server with Ts.ED:
1import {Configuration, Inject} from "@tsed/di"; 2import {PlatformApplication} from "@tsed/common"; 3import "@tsed/platform-express"; 4import cookieParser from "cookie-parser"; 5import compress from "compress"; 6import methodOverride from "method-override"; 7 8@Configuration({ 9 port: 3000, 10 middlewares: ["cookie-parser", "compression", "method-override", "json-parser", "urlencoded-parser"] 11}) 12export class Server {}
To run your server, you have to use Platform API to bootstrap your application with the expected platform like Express.
1import {$log} from "@tsed/common"; 2import {PlatformExpress} from "@tsed/platform-express"; 3import {Server} from "./Server.js"; 4 5async function bootstrap() { 6 try { 7 $log.debug("Start server..."); 8 const platform = await PlatformExpress.bootstrap(Server); 9 10 await platform.listen(); 11 $log.debug("Server initialized"); 12 } catch (er) { 13 $log.error(er); 14 } 15} 16 17bootstrap();
To customize the server settings see Configure server with decorator
This is a simple controller to expose user resource. It use decorators to build the endpoints:
1import {Inject} from "@tsed/di"; 2import {Summary} from "@tsed/swagger"; 3import { 4 Controller, 5 Get, 6 QueryParams, 7 PathParams, 8 Delete, 9 Post, 10 Required, 11 BodyParams, 12 Status, 13 Put, 14 Returns, 15 ReturnsArray 16} from "@tsed/common"; 17import {BadRequest} from "@tsed/exceptions"; 18import {UsersService} from "../services/UsersService.js"; 19import {User} from "../models/User.js"; 20 21@Controller("/users") 22export class UsersCtrl { 23 @Inject() 24 private usersService: UsersService; 25 26 @Get("/:id") 27 @Summary("Get a user from his Id") 28 @Returns(User) 29 async getUser(@PathParams("id") id: string): Promise<User> { 30 return this.usersService.findById(id); 31 } 32 33 @Post("/") 34 @Status(201) 35 @Summary("Create a new user") 36 @Returns(User) 37 async postUser(@Required() @BodyParams() user: User): Promise<User> { 38 return this.usersService.save(user); 39 } 40 41 @Put("/:id") 42 @Status(201) 43 @Summary("Update the given user") 44 @Returns(User) 45 async putUser(@PathParams("id") id: string, @Required() @BodyParams() user: User): Promise<User> { 46 if (user.id !== id) { 47 throw new BadRequest("ID mismatch with the given payload"); 48 } 49 50 return this.usersService.save(user); 51 } 52 53 @Delete("/:id") 54 @Summary("Remove a user") 55 @Status(204) 56 async deleteUser(@PathParams("id") @Required() id: string): Promise<User> { 57 await this.usersService.delete(user); 58 } 59 60 @Get("/") 61 @Summary("Get all users") 62 @Returns(200, Array).Of(User) 63 async findUser(@QueryParams("name") name: string) { 64 return this.usersService.find({name}); 65 } 66}
Please read contributing guidelines here.
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
The MIT License (MIT)
Copyright (c) 2016 - 2023 Romain Lenzotti
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.
No vulnerabilities found.
Reason
30 commit(s) and 11 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
SAST tool detected but not run on all commits
Details
Reason
Found 2/21 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
106 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@tsed/exceptions
HTTP exceptions module for Ts.ED Framework and other pure Express application
@tsed/common
A TypeScript Framework on top of Express
@tsed/engines
Template engines library. Provide an API to adding custom engines from decorators.
@tsed/di
DI module for Ts.ED Framework