typings for absolute-url (#47031)

This commit is contained in:
Tomasz Pluskiewicz 2020-08-28 02:05:07 +02:00 committed by GitHub
parent 1ffd978095
commit d9e47130b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import express = require('express');
import absoluteUrl = require('absolute-url');
const app = express();
app.use(absoluteUrl());
app.get('/', (req) => {
absoluteUrl.attach(req);
const url: string = req.absoluteUrl();
});

21
types/absolute-url/index.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
// Type definitions for absolute-url 1.2
// Project: https://github.com/zazukoians/absolute-url
// Definitions by: tpluscode <https://github.com/tpluscode>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { RequestHandler, Request } from "express";
declare module 'express-serve-static-core' {
interface Request {
absoluteUrl(): string;
}
}
interface AbsoluteUrl {
(): RequestHandler;
attach(req: Request): void;
}
declare const middleware: AbsoluteUrl;
export = middleware;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"absolute-url-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }