Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@tsed/common
Advanced tools
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 framework on top of Express that helps you to write your application in TypeScript (or in ES6). It provides a lot of decorators to make your code more readable and less error-prone.
Documentation is available on https://tsed.io
See our getting started here to create new Ts.ED project or use our CLI
Examples are available on https://tsed.io/tutorials/
Here an example to create a Server with Ts.ED:
import {Configuration, Inject} from "@tsed/di";
import {PlatformApplication} from "@tsed/platform-http";
import "@tsed/platform-express";
import Path from "path";
import cookieParser from "cookie-parser";
import compress from "compression";
import methodOverride from "method-override";
@Configuration({
port: 3000,
middlewares: ["cookie-parser", "compression", "method-override", "json-parser", "urlencoded-parser"]
})
export class Server {}
To run your server, you have to use Platform API to bootstrap your application with the expected platform like Express.
import {$log} from "@tsed/logger";
import {PlatformExpress} from "@tsed/platform-express";
import {Server} from "./Server.js";
async function bootstrap() {
try {
$log.debug("Start server...");
const platform = await PlatformExpress.bootstrap(Server);
await platform.listen();
$log.debug("Server initialized");
} catch (er) {
$log.error(er);
}
}
bootstrap();
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:
import {Inject} from "@tsed/di";
import {Summary} from "@tsed/swagger";
import {
Returns,
ReturnsArray,
Controller,
Get,
QueryParams,
PathParams,
Delete,
Post,
Required,
BodyParams,
Status,
Put
} from "@tsed/schema";
import {BadRequest} from "@tsed/exceptions";
import {UsersService} from "../services/UsersService.js";
import {User} from "../models/User.js";
@Controller("/users")
export class UsersCtrl {
@Inject()
protected usersService: UsersService;
@Get("/:id")
@Summary("Get a user from his Id")
@Returns(User)
async getUser(@PathParams("id") id: string): Promise<User> {
return this.usersService.findById(id);
}
@Post("/")
@Status(201)
@Summary("Create a new user")
@Returns(User)
async postUser(@Required() @BodyParams() user: User): Promise<User> {
return this.usersService.save(user);
}
@Put("/:id")
@Status(201)
@Summary("Update the given user")
@Returns(User)
async putUser(@PathParams("id") id: string, @Required() @BodyParams() user: User): Promise<User> {
if (user.id !== id) {
throw new BadRequest("ID mismatch with the given payload");
}
return this.usersService.save(user);
}
@Delete("/:id")
@Summary("Remove a user")
@Status(204)
async deleteUser(@PathParams("id") @Required() id: string): Promise<User> {
await this.usersService.delete(user);
}
@Get("/")
@Summary("Get all users")
@ReturnsArray(User)
async findUser(@QueryParams("name") name: string) {
return this.usersService.find({name});
}
}
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 - 2020 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.
FAQs
A TypeScript Framework on top of Express
We found that @tsed/common demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.