mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
feat: Add fastify-static typings
This commit is contained in:
16
types/fastify-static/fastify-static-tests.ts
Normal file
16
types/fastify-static/fastify-static-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import path = require("path");
|
||||
import fastify = require("fastify");
|
||||
import fastifyStatic = require("fastify-static");
|
||||
|
||||
const app = fastify();
|
||||
|
||||
app.register<fastifyStatic.FastifyStaticOptions>(fastifyStatic, {
|
||||
root: path.join(__dirname, "public"),
|
||||
prefix: "/public/", // optional: default '/'
|
||||
immutable: true,
|
||||
maxAge: 42
|
||||
});
|
||||
|
||||
app.get("/another/path", (req, reply) => {
|
||||
reply.sendFile("myHtml.html"); // serving path.join(__dirname, 'public', 'myHtml.html') directly
|
||||
});
|
||||
40
types/fastify-static/index.d.ts
vendored
Normal file
40
types/fastify-static/index.d.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Type definitions for fastify-static 0.14
|
||||
// Project: https://github.com/fastify/fastify-static
|
||||
// Definitions by: Leonhard Melzer <https://github.com/leomelzer>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Server, IncomingMessage, ServerResponse } from "http";
|
||||
import * as fastify from "fastify";
|
||||
|
||||
declare module "fastify" {
|
||||
interface FastifyReply<HttpResponse> {
|
||||
sendFile(filename: string): FastifyReply<HttpResponse>;
|
||||
}
|
||||
}
|
||||
|
||||
declare function fastifyStatic(): void;
|
||||
|
||||
declare namespace fastifyStatic {
|
||||
interface FastifyStaticOptions {
|
||||
root: string;
|
||||
prefix?: string;
|
||||
serve?: boolean;
|
||||
decorateReply?: boolean;
|
||||
schemaHide?: boolean;
|
||||
setHeaders?: () => void;
|
||||
|
||||
// Passed on to `send`
|
||||
acceptRanges?: boolean;
|
||||
cacheControl?: boolean;
|
||||
dotfiles?: boolean;
|
||||
etag?: boolean;
|
||||
extensions?: string[];
|
||||
immutable?: boolean;
|
||||
index?: string[];
|
||||
lastModified?: boolean;
|
||||
maxAge?: string | number;
|
||||
}
|
||||
}
|
||||
|
||||
export = fastifyStatic;
|
||||
6
types/fastify-static/package.json
Normal file
6
types/fastify-static/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"fastify": "^1.11.2"
|
||||
}
|
||||
}
|
||||
16
types/fastify-static/tsconfig.json
Normal file
16
types/fastify-static/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "fastify-static-tests.ts"]
|
||||
}
|
||||
1
types/fastify-static/tslint.json
Normal file
1
types/fastify-static/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user