Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@types/serve-static
Advanced tools
The @types/serve-static package contains TypeScript type definitions for the serve-static middleware, which is used with Node.js HTTP servers to serve static files. These type definitions allow TypeScript developers to use serve-static in a type-safe manner, ensuring that they use the correct types for function arguments, return types, and object properties.
Serve static files
This code sample demonstrates how to use serve-static with Express to serve static files from the 'public' directory. It also specifies that 'index.html' or 'index.htm' should be used as the default file to serve if a directory is requested.
import * as express from 'express';
import * as serveStatic from 'serve-static';
const app = express();
app.use(serveStatic('public', {'index': ['index.html', 'index.htm']}));
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
Express is a web application framework for Node.js, designed for building web applications and APIs. It is often used in conjunction with serve-static to serve static files, but it also provides a wide range of other features such as routing, middleware, template engines, and more.
Koa-static is similar to serve-static but is designed for use with Koa, another web framework for Node.js. It provides similar functionality for serving static files in Koa applications.
Connect-static is a middleware for Connect, which is an extensible HTTP server framework for Node.js and is used as the foundation for Express. It provides static file serving capabilities similar to serve-static.
npm install --save @types/serve-static
This package contains type definitions for serve-static 1.7.1 (https://github.com/expressjs/serve-static).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/serve-static
Additional Details
These definitions were written by Uros Smolnik https://github.com/urossmolnik/.
FAQs
TypeScript definitions for serve-static
The npm package @types/serve-static receives a total of 18,648,082 weekly downloads. As such, @types/serve-static popularity was classified as popular.
We found that @types/serve-static demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.