
Product
Socket Now Supports pylock.toml Files
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
@types/serve-index
Advanced tools
TypeScript definitions for serve-index
The @types/serve-index package provides TypeScript type definitions for the serve-index package, which is used to serve pages that display directory listings for a given path in your web server. These type definitions enable TypeScript developers to use serve-index with type safety, ensuring that they use the API correctly according to the expected types.
Type Definitions for Directory Listing Configuration
This feature allows developers to configure directory listings with specific options such as displaying icons and filtering files. The type definitions ensure that the configuration options passed to serveIndex are correctly typed.
import * as express from 'express';
import * as serveIndex from 'serve-index';
const app = express();
app.use('/files', serveIndex('path/to/directory', {
icons: true,
filter: (filename, index, files, dir) => files[index].name.endsWith('.txt')
}));
serve-index is the JavaScript package that @types/serve-index provides types for. It allows you to serve up directory listings for a specified path on your server. While serve-index itself is used in JavaScript environments, @types/serve-index is specifically used in TypeScript environments to add type safety.
Express is a web application framework for Node.js, designed for building web applications and APIs. It is not specifically similar to @types/serve-index, but it often works in conjunction with serve-index for serving static files and directories in Express applications. Express itself does not provide directory listing capabilities, which is why serve-index or similar packages are used.
npm install --save @types/serve-index
This package contains type definitions for serve-index (https://github.com/expressjs/serve-index).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/serve-index.
import { Handler } from "express";
import { Stats } from "fs";
/** Serves pages that contain directory listings for a given path. */
declare function serveIndex(path: string, options?: serveIndex.Options): Handler;
declare namespace serveIndex {
interface File {
name: string;
stat: Stats;
}
interface Locals {
directory: string;
displayIcons: boolean;
fileList: File[];
name: string;
stat: Stats;
path: string;
style: string;
viewName: string;
}
type TemplateCallback = (error: Error | null, htmlString?: string) => void;
interface Options {
filter?: ((filename: string, index: number, files: File[], dir: string) => boolean) | undefined;
hidden?: boolean | undefined;
icons?: boolean | undefined;
stylesheet?: string | undefined;
template?: string | ((locals: Locals, callback: TemplateCallback) => void) | undefined;
view?: string | undefined;
}
}
export = serveIndex;
These definitions were written by Tanguy Krotoff.
FAQs
TypeScript definitions for serve-index
We found that @types/serve-index demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.
Research
Security News
Malicious Ruby gems typosquat Fastlane plugins to steal Telegram bot tokens, messages, and files, exploiting demand after Vietnam’s Telegram ban.