mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add express-async-wrap (#35030)
* adds types for express-async-wrap * Adds express-async-wrap properly * Adds typescript version to express-async-wrap * removes unnecessary generics * removes unnecessary comment * fix: now uses export default
This commit is contained in:
parent
1e697cb6e6
commit
a807e4e416
17
types/express-async-wrap/express-async-wrap-tests.ts
Normal file
17
types/express-async-wrap/express-async-wrap-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import asyncWrap from 'express-async-wrap';
|
||||
import express = require('express');
|
||||
|
||||
const app = express();
|
||||
|
||||
const promise = new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve("Success");
|
||||
}, 250);
|
||||
});
|
||||
|
||||
const asyncHandler = async (_: express.Request, res: express.Response) => {
|
||||
await promise;
|
||||
res.send('promise awaited');
|
||||
};
|
||||
|
||||
app.get('/', asyncWrap(asyncHandler));
|
||||
18
types/express-async-wrap/index.d.ts
vendored
Normal file
18
types/express-async-wrap/index.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Type definitions for express-async-wrap 1.0
|
||||
// Project: https://github.com/Greenfields/express-async-wrap#readme
|
||||
// Definitions by: Remy Oudemans <https://github.com/remyoudemans>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import { NextFunction } from 'connect';
|
||||
import { Response, RequestHandler, ErrorRequestHandler, Request } from 'express-serve-static-core';
|
||||
|
||||
declare function asyncWrap(
|
||||
handler: (req: Request, res: Response, next: NextFunction) => Promise<void>
|
||||
): RequestHandler;
|
||||
|
||||
declare function asyncWrap(
|
||||
handler: (err: any, req: Request, res: Response, next: NextFunction) => Promise<void>,
|
||||
): ErrorRequestHandler;
|
||||
|
||||
export default asyncWrap;
|
||||
23
types/express-async-wrap/tsconfig.json
Normal file
23
types/express-async-wrap/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"express-async-wrap-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/express-async-wrap/tslint.json
Normal file
1
types/express-async-wrap/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user