express-typed
Advanced tools
Comparing version 0.3.0 to 0.3.1
import express, { Response, NextFunction } from "express"; | ||
import { UnionToIntersection, WithDefault } from "./type-utils"; | ||
export type TypedResponse<Res extends Partial<TypedResponseRes> = TypedResponseRes, Info extends any[] = []> = { | ||
status<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
status<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
status: T; | ||
}]>; | ||
links<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
links<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
links: T; | ||
}]>; | ||
sendStatus<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
sendStatus<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
sendStatus: T; | ||
}]>; | ||
contentType<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
contentType<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
contentType: T; | ||
}]>; | ||
type<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
type<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
type: T; | ||
}]>; | ||
format<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
format<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
format: T; | ||
}]>; | ||
attachment<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
attachment<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
attachment: T; | ||
}]>; | ||
json<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
json<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
json: T; | ||
}]>; | ||
jsonp<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
jsonp<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
jsonp: T; | ||
}]>; | ||
send<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { | ||
send<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { | ||
send: T; | ||
@@ -38,2 +38,3 @@ }]>; | ||
locals: Record<string, any>; | ||
routes: any; | ||
}; | ||
@@ -40,0 +41,0 @@ export type SendMethod = "send" | "json" | "jsonp"; |
{ | ||
"name": "express-typed", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "end-to-end typesafe TypeScript wrapper for Express.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Eliav2/express-typed" | ||
}, | ||
"homepage": "https://github.com/Eliav2/express-typed", | ||
"bugs": "https://github.com/Eliav2/express-typed/issues", | ||
"type": "module", | ||
@@ -18,3 +24,3 @@ "main": "dist/express-typed.js", | ||
"author": "", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"devDependencies": { | ||
@@ -24,4 +30,6 @@ "@types/express": "^4.17.21", | ||
"@types/qs": "^6.9.15", | ||
"@types/supertest": "^6.0.2", | ||
"@vitest/coverage-v8": "^1.5.2", | ||
"express": "^4.19.2", | ||
"supertest": "^7.0.0", | ||
"typescript": "^5.4.2" | ||
@@ -28,0 +36,0 @@ }, |
@@ -6,17 +6,16 @@ import express, { Request, Response, NextFunction } from "express"; | ||
export type TypedResponse<Res extends Partial<TypedResponseRes> = TypedResponseRes, Info extends any[] = []> = { | ||
status<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { status: T }]>; | ||
links<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { links: T }]>; | ||
sendStatus<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { sendStatus: T }]>; | ||
contentType<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { contentType: T }]>; | ||
type<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { type: T }]>; | ||
format<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { format: T }]>; | ||
attachment<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { attachment: T }]>; | ||
status<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { status: T }]>; | ||
links<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { links: T }]>; | ||
sendStatus<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { sendStatus: T }]>; | ||
contentType<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { contentType: T }]>; | ||
type<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { type: T }]>; | ||
format<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { format: T }]>; | ||
attachment<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { attachment: T }]>; | ||
json<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { json: T }]>; | ||
jsonp<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { jsonp: T }]>; | ||
send<const T extends Res['body']>(arg: T): TypedResponse<Res, [...Info, { send: T }]>; | ||
// } & Response<Res["ResBody"], Res["Locals"] extends Record<string, any> ? Res["Locals"] : Record<string, any>>; | ||
json<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { json: T }]>; | ||
jsonp<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { jsonp: T }]>; | ||
send<const T extends Res["body"]>(arg: T): TypedResponse<Res, [...Info, { send: T }]>; | ||
} & Response<Res["body"], WithDefault<Res["locals"], Record<string, any>>>; | ||
export type TypedResponseRes = { body: any; locals: Record<string, any> }; | ||
export type TypedResponseRes = { body: any; locals: Record<string, any>; routes: any }; | ||
@@ -23,0 +22,0 @@ // The different methods that can be used to send a response, those have special meaning |
Sorry, the diff of this file is not supported yet
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
17875
0
1
0
8