Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

serve-static.d.ts 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Type definitions for serve-static 1.7.1
  2. // Project: https://github.com/expressjs/serve-static
  3. // Definitions by: Uros Smolnik <https://github.com/urossmolnik/>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. /* =================== USAGE ===================
  6. import serveStatic = require('serve-static');
  7. app.use(serveStatic('public/ftp', {'index': ['default.html', 'default.htm']}))
  8. =============================================== */
  9. /// <reference path="../express/express.d.ts" />
  10. /// <reference path="../mime/mime.d.ts" />
  11. declare module "serve-static" {
  12. import * as express from "express";
  13. /**
  14. * Create a new middleware function to serve files from within a given root directory.
  15. * The file to serve will be determined by combining req.url with the provided root directory.
  16. * When a file is not found, instead of sending a 404 response, this module will instead call next() to move on to the next middleware, allowing for stacking and fall-backs.
  17. */
  18. function serveStatic(root: string, options?: {
  19. /**
  20. * Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
  21. * Note this check is done on the path itself without checking if the path actually exists on the disk.
  22. * If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
  23. * The default value is 'ignore'.
  24. * 'allow' No special treatment for dotfiles
  25. * 'deny' Send a 403 for any request for a dotfile
  26. * 'ignore' Pretend like the dotfile does not exist and call next()
  27. */
  28. dotfiles?: string;
  29. /**
  30. * Enable or disable etag generation, defaults to true.
  31. */
  32. etag?: boolean;
  33. /**
  34. * Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
  35. * The first that exists will be served. Example: ['html', 'htm'].
  36. * The default value is false.
  37. */
  38. extensions?: string[];
  39. /**
  40. * By default this module will send "index.html" files in response to a request on a directory.
  41. * To disable this set false or to supply a new index pass a string or an array in preferred order.
  42. */
  43. index?: boolean;
  44. /**
  45. * Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
  46. */
  47. lastModified?: boolean;
  48. /**
  49. * Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
  50. */
  51. maxAge?: number;
  52. /**
  53. * Redirect to trailing "/" when the pathname is a dir. Defaults to true.
  54. */
  55. redirect?: boolean;
  56. /**
  57. * Function to set custom headers on response. Alterations to the headers need to occur synchronously.
  58. * The function is called as fn(res, path, stat), where the arguments are:
  59. * res the response object
  60. * path the file path that is being sent
  61. * stat the stat object of the file that is being sent
  62. */
  63. setHeaders?: (res: express.Response, path: string, stat: any) => any;
  64. }): express.Handler;
  65. import * as m from "mime";
  66. module serveStatic {
  67. var mime: typeof m;
  68. }
  69. export = serveStatic;
  70. }