Initial commit - Event Planner application

This commit is contained in:
mberlin
2026-03-18 14:55:56 -03:00
commit 86d779eb4d
7548 changed files with 1006324 additions and 0 deletions

55
node_modules/@nestjs/serve-static/.circleci/config.yml generated vendored Normal file
View File

@@ -0,0 +1,55 @@
version: 2
aliases:
- &restore-cache
restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- &install-deps
run:
name: Install dependencies
command: npm install --ignore-scripts
- &build-packages
run:
name: Build
command: npm run build
jobs:
build:
working_directory: ~/nest
docker:
- image: cimg/node:22.20.0
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm install --ignore-scripts
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Build
command: npm run build
e2e_test:
working_directory: ~/nest
docker:
- image: cimg/node:22.20.0
steps:
- checkout
- *restore-cache
- *install-deps
- run:
name: E2E tests
command: npm run test:e2e
workflows:
version: 2
build-and-test:
jobs:
- build
- e2e_test:
requires:
- build

1
node_modules/@nestjs/serve-static/.husky/commit-msg generated vendored Normal file
View File

@@ -0,0 +1 @@
npx --no-install commitlint --edit $1

1
node_modules/@nestjs/serve-static/.husky/pre-commit generated vendored Normal file
View File

@@ -0,0 +1 @@
npx --no-install lint-staged

24
node_modules/@nestjs/serve-static/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,24 @@
(The MIT License)
Copyright (c)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

82
node_modules/@nestjs/serve-static/README.md generated vendored Normal file
View File

@@ -0,0 +1,82 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
`@nestjs/serve-static` package for [Nest](https://github.com/nestjs/nest), useful to serve static content like Single Page Applications (SPA). However, if you are building MVC application or want to serve assets files (images, docs), use the `useStaticAssets()` method (read more [here](https://docs.nestjs.com/techniques/mvc)) instead.
## Installation
```bash
$ npm i --save @nestjs/serve-static
```
## Example
See full example [here](https://github.com/nestjs/nest/tree/master/sample/24-serve-static).
## Usage
Simply import `ServeStaticModule` in your Nest application.
```typescript
import { Module } from '@nestjs/common';
import { join } from 'path';
import { ServeStaticModule } from '@nestjs/serve-static';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client')
})
]
})
export class ApplicationModule {}
```
## API Spec
The `forRoot()` method takes an options object with a few useful properties.
| Property | Type | Description |
| -------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `rootPath` | string | Static files root directory. Default: `"client"` |
| `serveRoot` | string | Root path under which static app will be served. Default: `""` |
| `renderPath` | string / RegExp | Path to render static app (concatenated with the `serveRoot` value). Default: \* (wildcard - all paths). Note: `RegExp` is not supported by the `@nestjs/platform-fastify`. |
| `exclude` | string[] | Paths to exclude when serving the static app. WARNING! Not supported by `fastify`. If you use `fastify`, you can exclude routes using regexp (set the `renderPath` to a regular expression) instead. |
| `serveStaticOptions` | Object | Serve static options (static files) |
| `useGlobalPrefix` | boolean | If `true`, static app will be prefixed by the global prefix set through `setGlobalPrefix()`. Default: `false` https://docs.nestjs.com/faq/global-prefix |
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

8
node_modules/@nestjs/serve-static/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export * from './interfaces/serve-static-options.interface';
export * from './loaders/abstract.loader';
export * from './loaders/express.loader';
export * from './loaders/fastify.loader';
export * from './loaders/noop.loader';
export * from './serve-static.constants';
export * from './serve-static.module';
export * from './serve-static.providers';

24
node_modules/@nestjs/serve-static/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./interfaces/serve-static-options.interface"), exports);
__exportStar(require("./loaders/abstract.loader"), exports);
__exportStar(require("./loaders/express.loader"), exports);
__exportStar(require("./loaders/fastify.loader"), exports);
__exportStar(require("./loaders/noop.loader"), exports);
__exportStar(require("./serve-static.constants"), exports);
__exportStar(require("./serve-static.module"), exports);
__exportStar(require("./serve-static.providers"), exports);

View File

@@ -0,0 +1,36 @@
import { Provider, Type } from '@nestjs/common';
import { ModuleMetadata } from '@nestjs/common/interfaces';
export interface ServeStaticModuleOptions {
rootPath?: string;
renderPath?: string | RegExp;
useGlobalPrefix?: boolean;
serveRoot?: string;
exclude?: string[];
serveStaticOptions?: {
acceptRanges?: boolean;
cacheControl?: boolean;
dotfiles?: string;
etag?: boolean;
fallthrough?: boolean;
extensions?: string[];
immutable?: boolean;
index?: boolean | string | string[];
lastModified?: boolean;
maxAge?: number | string;
redirect?: boolean;
setHeaders?: (res: any, path: string, stat: any) => any;
preCompressed?: boolean;
decorateReply?: boolean;
};
}
export interface ServeStaticModuleOptionsFactory {
createLoggerOptions(): Promise<ServeStaticModuleOptions[]> | ServeStaticModuleOptions[];
}
export interface ServeStaticModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
isGlobal?: boolean;
useExisting?: Type<ServeStaticModuleOptionsFactory>;
useClass?: Type<ServeStaticModuleOptionsFactory>;
useFactory?: (...args: any[]) => Promise<ServeStaticModuleOptions[]> | ServeStaticModuleOptions[];
inject?: any[];
extraProviders?: Provider[];
}

View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -0,0 +1,6 @@
import { AbstractHttpAdapter, ApplicationConfig } from '@nestjs/core';
import { ServeStaticModuleOptions } from '../interfaces/serve-static-options.interface';
export declare abstract class AbstractLoader {
abstract register(httpAdapter: AbstractHttpAdapter, config: ApplicationConfig, options: ServeStaticModuleOptions[]): any;
getIndexFilePath(clientPath: string): string;
}

View File

@@ -0,0 +1,20 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractLoader = void 0;
const common_1 = require("@nestjs/common");
const path_1 = require("path");
let AbstractLoader = class AbstractLoader {
getIndexFilePath(clientPath) {
return (0, path_1.join)(clientPath, 'index.html');
}
};
exports.AbstractLoader = AbstractLoader;
exports.AbstractLoader = AbstractLoader = __decorate([
(0, common_1.Injectable)()
], AbstractLoader);

View File

@@ -0,0 +1,6 @@
import { AbstractHttpAdapter, ApplicationConfig } from '@nestjs/core';
import { ServeStaticModuleOptions } from '../interfaces/serve-static-options.interface';
import { AbstractLoader } from './abstract.loader';
export declare class ExpressLoader extends AbstractLoader {
register(httpAdapter: AbstractHttpAdapter, config: ApplicationConfig, optionsArr: ServeStaticModuleOptions[]): void;
}

View File

@@ -0,0 +1,118 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpressLoader = void 0;
const common_1 = require("@nestjs/common");
const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
const fs = __importStar(require("fs"));
const serve_static_constants_1 = require("../serve-static.constants");
const is_route_excluded_util_1 = require("../utils/is-route-excluded.util");
const validate_global_prefix_util_1 = require("../utils/validate-global-prefix.util");
const validate_path_util_1 = require("../utils/validate-path.util");
const abstract_loader_1 = require("./abstract.loader");
let ExpressLoader = class ExpressLoader extends abstract_loader_1.AbstractLoader {
register(httpAdapter, config, optionsArr) {
const app = httpAdapter.getInstance();
const globalPrefix = config.getGlobalPrefix();
const express = (0, load_package_util_1.loadPackage)('express', 'ServeStaticModule', () => require('express'));
optionsArr.forEach((options) => {
options.renderPath = options.renderPath ?? serve_static_constants_1.DEFAULT_EXPRESS_RENDER_PATH;
const clientPath = options.rootPath ?? serve_static_constants_1.DEFAULT_ROOT_PATH;
const indexFilePath = this.getIndexFilePath(clientPath);
const renderFn = (req, res, next) => {
if (!(0, is_route_excluded_util_1.isRouteExcluded)(req, options.exclude)) {
if (options.serveStaticOptions?.setHeaders) {
const stat = fs.statSync(indexFilePath);
options.serveStaticOptions.setHeaders(res, indexFilePath, stat);
}
res.sendFile(indexFilePath, null, (err) => {
if (err) {
const error = new common_1.NotFoundException(err.message);
res.status(error.getStatus()).send(error.getResponse());
}
});
}
else {
next();
}
};
if (globalPrefix &&
options.useGlobalPrefix &&
(0, validate_global_prefix_util_1.validateGlobalPrefix)(globalPrefix)) {
options.serveRoot = `/${globalPrefix}${options.serveRoot || ''}`;
}
if (options.serveRoot) {
app.use(options.serveRoot, express.static(clientPath, options.serveStaticOptions));
const renderPath = typeof options.serveRoot === 'string'
? options.serveRoot + (0, validate_path_util_1.validatePath)(options.renderPath)
: options.serveRoot;
app.get(renderPath, renderFn);
}
else {
app.use(express.static(clientPath, options.serveStaticOptions));
app.get(options.renderPath, renderFn);
}
app.use((err, req, _res, next) => {
if ((0, is_route_excluded_util_1.isRouteExcluded)(req, options.exclude)) {
const method = httpAdapter.getRequestMethod(req);
const url = httpAdapter.getRequestUrl(req);
return next(new common_1.NotFoundException(`Cannot ${method} ${url}`));
}
if (err instanceof common_1.HttpException) {
throw err;
}
else if (err?.message?.includes('ENOENT')) {
throw new common_1.NotFoundException(err.message);
}
else if (err?.code === 'ENOENT') {
throw new common_1.NotFoundException(`ENOENT: ${err.message}`);
}
else {
next(err);
}
});
});
}
};
exports.ExpressLoader = ExpressLoader;
exports.ExpressLoader = ExpressLoader = __decorate([
(0, common_1.Injectable)()
], ExpressLoader);

View File

@@ -0,0 +1,6 @@
import { AbstractHttpAdapter, ApplicationConfig } from '@nestjs/core';
import { ServeStaticModuleOptions } from '../interfaces/serve-static-options.interface';
import { AbstractLoader } from './abstract.loader';
export declare class FastifyLoader extends AbstractLoader {
register(httpAdapter: AbstractHttpAdapter, config: ApplicationConfig, optionsArr: ServeStaticModuleOptions[]): void;
}

View File

@@ -0,0 +1,109 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FastifyLoader = void 0;
const common_1 = require("@nestjs/common");
const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
const fs = __importStar(require("fs"));
const serve_static_constants_1 = require("../serve-static.constants");
const validate_global_prefix_util_1 = require("../utils/validate-global-prefix.util");
const validate_path_util_1 = require("../utils/validate-path.util");
const abstract_loader_1 = require("./abstract.loader");
let FastifyLoader = class FastifyLoader extends abstract_loader_1.AbstractLoader {
register(httpAdapter, config, optionsArr) {
const app = httpAdapter.getInstance();
const globalPrefix = config.getGlobalPrefix();
const fastifyStatic = (0, load_package_util_1.loadPackage)('@fastify/static', 'ServeStaticModule', () => require('@fastify/static'));
optionsArr.forEach((options) => {
options.renderPath = options.renderPath ?? serve_static_constants_1.DEFAULT_FASTIFY_RENDER_PATH;
const clientPath = options.rootPath ?? serve_static_constants_1.DEFAULT_ROOT_PATH;
const indexFilePath = this.getIndexFilePath(clientPath);
if (globalPrefix &&
options.useGlobalPrefix &&
(0, validate_global_prefix_util_1.validateGlobalPrefix)(globalPrefix)) {
options.serveRoot = `/${globalPrefix}${options.serveRoot || ''}`;
}
const renderFn = (req, res) => {
if (!options.serveStaticOptions?.fallthrough) {
const error = new common_1.NotFoundException();
res.status(error.getStatus()).send(error.getResponse());
return;
}
fs.stat(indexFilePath, (err, stat) => {
if (err) {
const error = new common_1.NotFoundException();
res.status(error.getStatus()).send(error.getResponse());
return;
}
const stream = fs.createReadStream(indexFilePath);
if (options.serveStaticOptions?.setHeaders) {
options.serveStaticOptions.setHeaders(res, indexFilePath, stat);
}
res.type('text/html').send(stream);
});
};
if (options.serveRoot) {
app.register(fastifyStatic, {
root: clientPath,
...(options.serveStaticOptions || {}),
wildcard: false,
prefix: options.serveRoot
});
const renderPath = typeof options.serveRoot === 'string'
? options.serveRoot + (0, validate_path_util_1.validatePath)(options.renderPath)
: options.serveRoot;
app.get(renderPath, renderFn);
}
else {
app.register(fastifyStatic, {
root: clientPath,
...(options.serveStaticOptions || {}),
wildcard: false
});
app.get(options.renderPath, renderFn);
}
});
}
};
exports.FastifyLoader = FastifyLoader;
exports.FastifyLoader = FastifyLoader = __decorate([
(0, common_1.Injectable)()
], FastifyLoader);

View File

@@ -0,0 +1,6 @@
import { AbstractHttpAdapter, ApplicationConfig } from '@nestjs/core';
import { ServeStaticModuleOptions } from '../interfaces/serve-static-options.interface';
import { AbstractLoader } from './abstract.loader';
export declare class NoopLoader extends AbstractLoader {
register(httpAdapter: AbstractHttpAdapter, config: ApplicationConfig, options: ServeStaticModuleOptions[]): void;
}

View File

@@ -0,0 +1,18 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NoopLoader = void 0;
const common_1 = require("@nestjs/common");
const abstract_loader_1 = require("./abstract.loader");
let NoopLoader = class NoopLoader extends abstract_loader_1.AbstractLoader {
register(httpAdapter, config, options) { }
};
exports.NoopLoader = NoopLoader;
exports.NoopLoader = NoopLoader = __decorate([
(0, common_1.Injectable)()
], NoopLoader);

View File

@@ -0,0 +1,4 @@
export declare const SERVE_STATIC_MODULE_OPTIONS = "SERVE_STATIC_MODULE_OPTIONS";
export declare const DEFAULT_ROOT_PATH = "client";
export declare const DEFAULT_EXPRESS_RENDER_PATH = "{*any}";
export declare const DEFAULT_FASTIFY_RENDER_PATH = "*";

View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_FASTIFY_RENDER_PATH = exports.DEFAULT_EXPRESS_RENDER_PATH = exports.DEFAULT_ROOT_PATH = exports.SERVE_STATIC_MODULE_OPTIONS = void 0;
exports.SERVE_STATIC_MODULE_OPTIONS = 'SERVE_STATIC_MODULE_OPTIONS';
exports.DEFAULT_ROOT_PATH = 'client';
exports.DEFAULT_EXPRESS_RENDER_PATH = '{*any}';
exports.DEFAULT_FASTIFY_RENDER_PATH = '*';

View File

@@ -0,0 +1,16 @@
import { DynamicModule, OnModuleInit } from '@nestjs/common';
import { ApplicationConfig, HttpAdapterHost } from '@nestjs/core';
import { ServeStaticModuleAsyncOptions, ServeStaticModuleOptions } from './interfaces/serve-static-options.interface';
import { AbstractLoader } from './loaders/abstract.loader';
export declare class ServeStaticModule implements OnModuleInit {
private readonly moduleOptions;
private readonly loader;
private readonly config;
private readonly httpAdapterHost;
constructor(moduleOptions: ServeStaticModuleOptions[], loader: AbstractLoader, config: ApplicationConfig, httpAdapterHost: HttpAdapterHost);
static forRoot(...options: ServeStaticModuleOptions[]): DynamicModule;
static forRootAsync(options: ServeStaticModuleAsyncOptions): DynamicModule;
private static createAsyncProviders;
private static createAsyncOptionsProvider;
onModuleInit(): void;
}

View File

@@ -0,0 +1,91 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var ServeStaticModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServeStaticModule = void 0;
const common_1 = require("@nestjs/common");
const core_1 = require("@nestjs/core");
const abstract_loader_1 = require("./loaders/abstract.loader");
const serve_static_constants_1 = require("./serve-static.constants");
const serve_static_providers_1 = require("./serve-static.providers");
let ServeStaticModule = ServeStaticModule_1 = class ServeStaticModule {
constructor(moduleOptions, loader, config, httpAdapterHost) {
this.moduleOptions = moduleOptions;
this.loader = loader;
this.config = config;
this.httpAdapterHost = httpAdapterHost;
}
static forRoot(...options) {
return {
module: ServeStaticModule_1,
providers: [
{
provide: serve_static_constants_1.SERVE_STATIC_MODULE_OPTIONS,
useValue: options
}
]
};
}
static forRootAsync(options) {
return {
module: ServeStaticModule_1,
imports: options.imports,
providers: [
...this.createAsyncProviders(options),
...(options.extraProviders || [])
],
exports: [serve_static_constants_1.SERVE_STATIC_MODULE_OPTIONS]
};
}
static createAsyncProviders(options) {
if (options.useExisting || options.useFactory) {
return [this.createAsyncOptionsProvider(options)];
}
return [
this.createAsyncOptionsProvider(options),
{
provide: options.useClass,
useClass: options.useClass
}
];
}
static createAsyncOptionsProvider(options) {
if (options.useFactory) {
return {
provide: serve_static_constants_1.SERVE_STATIC_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject || []
};
}
return {
provide: serve_static_constants_1.SERVE_STATIC_MODULE_OPTIONS,
useFactory: async (optionsFactory) => optionsFactory.createLoggerOptions(),
inject: [options.useExisting || options.useClass]
};
}
onModuleInit() {
const httpAdapter = this.httpAdapterHost.httpAdapter;
this.loader.register(httpAdapter, this.config, this.moduleOptions);
}
};
exports.ServeStaticModule = ServeStaticModule;
exports.ServeStaticModule = ServeStaticModule = ServeStaticModule_1 = __decorate([
(0, common_1.Module)({
providers: [...serve_static_providers_1.serveStaticProviders]
}),
__param(0, (0, common_1.Inject)(serve_static_constants_1.SERVE_STATIC_MODULE_OPTIONS)),
__metadata("design:paramtypes", [Array, abstract_loader_1.AbstractLoader,
core_1.ApplicationConfig,
core_1.HttpAdapterHost])
], ServeStaticModule);

View File

@@ -0,0 +1,2 @@
import { Provider } from '@nestjs/common';
export declare const serveStaticProviders: Provider[];

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serveStaticProviders = void 0;
const core_1 = require("@nestjs/core");
const abstract_loader_1 = require("./loaders/abstract.loader");
const express_loader_1 = require("./loaders/express.loader");
const fastify_loader_1 = require("./loaders/fastify.loader");
const noop_loader_1 = require("./loaders/noop.loader");
exports.serveStaticProviders = [
{
provide: abstract_loader_1.AbstractLoader,
useFactory: (httpAdapterHost) => {
if (!httpAdapterHost || !httpAdapterHost.httpAdapter) {
return new noop_loader_1.NoopLoader();
}
const httpAdapter = httpAdapterHost.httpAdapter;
if (httpAdapter &&
httpAdapter.constructor &&
httpAdapter.constructor.name === 'FastifyAdapter') {
return new fastify_loader_1.FastifyLoader();
}
return new express_loader_1.ExpressLoader();
},
inject: [core_1.HttpAdapterHost]
}
];

View File

@@ -0,0 +1 @@
export declare const isRouteExcluded: (req: any, paths?: string[]) => boolean;

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRouteExcluded = void 0;
const path_to_regexp_1 = require("path-to-regexp");
const isRouteExcluded = (req, paths = []) => {
return paths.some((path) => {
const { regexp } = (0, path_to_regexp_1.pathToRegexp)(path);
const queryParamsIndex = req.originalUrl.indexOf('?');
const pathname = queryParamsIndex >= 0
? req.originalUrl.slice(0, queryParamsIndex)
: req.originalUrl;
if (!regexp.exec(pathname + '/')) {
return false;
}
return true;
});
};
exports.isRouteExcluded = isRouteExcluded;

View File

@@ -0,0 +1,5 @@
export declare function loadPackage<T = any>(
packageName: string,
context: string,
loaderFn?: () => T
): T;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("@nestjs/common");
const MISSING_REQUIRED_DEPENDENCY = (name, reason) => `The "${name}" package is missing. Please, make sure to install this library ($ npm install ${name}) to take advantage of ${reason}.`;
const logger = new common_1.Logger('PackageLoader');
function loadPackage(packageName, context, loaderFn) {
try {
return loaderFn ? loaderFn() : require(packageName);
}
catch (e) {
logger.error(MISSING_REQUIRED_DEPENDENCY(packageName, context));
process.exit(1);
}
}
exports.loadPackage = loadPackage;

View File

@@ -0,0 +1 @@
export declare const validateGlobalPrefix: (globalPrefix: string) => boolean;

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateGlobalPrefix = void 0;
const validateGlobalPrefix = (globalPrefix) => !globalPrefix.match(/^(\/?)$/);
exports.validateGlobalPrefix = validateGlobalPrefix;

View File

@@ -0,0 +1 @@
export declare const validatePath: (path: string) => string;

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validatePath = void 0;
const validatePath = (path) => path && path.charAt(0) !== '/' ? `/${path}` : path;
exports.validatePath = validatePath;

41
node_modules/@nestjs/serve-static/eslint.config.mjs generated vendored Normal file
View File

@@ -0,0 +1,41 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['tests/**'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-require-imports': 'off',
},
},
);

1
node_modules/@nestjs/serve-static/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist';

6
node_modules/@nestjs/serve-static/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
exports.__esModule = true;
__export(require("./dist"));

83
node_modules/@nestjs/serve-static/package.json generated vendored Normal file
View File

@@ -0,0 +1,83 @@
{
"name": "@nestjs/serve-static",
"version": "5.0.4",
"description": "Nest - modern, fast, powerful node.js web framework (@serve-static)",
"author": "Kamil Mysliwiec",
"license": "MIT",
"scripts": {
"build": "npm run build:lib",
"build:lib": "tsc -p tsconfig.json",
"format": "prettier --write \"**/*.ts\"",
"lint": "eslint 'lib/**/*.ts' --fix",
"prepublish:npm": "npm run build",
"publish:npm": "npm publish --access public",
"prepublish:next": "npm run build",
"publish:next": "npm publish --access public --tag next",
"prerelease": "npm run build",
"release": "release-it",
"test:e2e": "jest --config ./tests/jest-e2e.json --runInBand",
"prepare": "husky"
},
"peerDependencies": {
"@fastify/static": "^8.0.4",
"@nestjs/common": "^11.0.2",
"@nestjs/core": "^11.0.2",
"express": "^5.0.1",
"fastify": "^5.2.1"
},
"peerDependenciesMeta": {
"express": {
"optional": true
},
"fastify": {
"optional": true
},
"@fastify/static": {
"optional": true
}
},
"devDependencies": {
"@commitlint/cli": "20.1.0",
"@commitlint/config-angular": "20.0.0",
"@eslint/eslintrc": "3.3.1",
"@eslint/js": "9.37.0",
"@fastify/static": "8.2.0",
"@nestjs/common": "11.1.6",
"@nestjs/core": "11.1.6",
"@nestjs/platform-express": "11.1.6",
"@nestjs/platform-fastify": "11.1.6",
"@nestjs/testing": "11.1.6",
"@types/jest": "30.0.0",
"@types/node": "22.18.9",
"@types/supertest": "6.0.3",
"eslint": "9.37.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-prettier": "5.5.4",
"express": "5.1.0",
"fastify": "5.6.1",
"globals": "16.4.0",
"husky": "9.1.7",
"jest": "30.2.0",
"lint-staged": "16.2.3",
"prettier": "3.6.2",
"reflect-metadata": "0.2.2",
"release-it": "19.0.5",
"rxjs": "7.8.2",
"supertest": "7.1.4",
"ts-jest": "29.4.5",
"typescript": "5.9.3",
"typescript-eslint": "8.46.0"
},
"lint-staged": {
"*.ts": [
"prettier --write"
]
},
"repository": {
"type": "git",
"url": "https://github.com/nestjs/serve-static"
},
"dependencies": {
"path-to-regexp": "8.3.0"
}
}

View File

@@ -0,0 +1,7 @@
<img src="/logo.svg" width="100" />
<h1>Static website</h1>
<ul>
<li><a href="/link-1">Link 1</a></li>
<li><a href="/link-2">Link 2</a></li>
<li><a href="/link-3">Link 3</a></li>
</ul>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,159 @@
import { INestApplication } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { Server } from 'net';
import request from 'supertest';
import { AppModule } from '../src/app.module';
import { NoopLogger } from '../utils/noop-logger';
describe('Express adapter', () => {
let server: Server;
let app: INestApplication;
describe('when middleware throws generic error', () => {
beforeAll(async () => {
app = await NestFactory.create(AppModule.withDefaults(), {
logger: new NoopLogger()
});
app.use((_req, _res, next) => next(new Error('Something went wrong')));
server = app.getHttpServer();
await app.init();
});
describe('GET /index.html', () => {
it('should return Iternal Server Error', async () => {
return request(server).get('/index.html').expect(500);
});
});
});
describe('when "fallthrough" option is set to "true"', () => {
beforeAll(async () => {
app = await NestFactory.create(AppModule.withFallthrough(), {
logger: new NoopLogger()
});
app.setGlobalPrefix('api');
server = app.getHttpServer();
await app.init();
});
describe('GET /api', () => {
it('should return "Hello, world!"', async () => {
return request(server).get('/api').expect(200).expect('Hello, world!');
});
});
describe('GET /', () => {
it('should return HTML file', async () => {
return request(server)
.get('/')
.expect(200)
.expect('Content-Type', /html/);
});
});
describe('GET /index.html', () => {
it('should return index page', async () => {
return request(server)
.get('/index.html')
.expect(200)
.expect('Content-Type', /html/)
.expect(/Static website/);
});
});
describe('GET /logo.svg', () => {
it('should return logo', async () => {
return request(server)
.get('/logo.svg')
.expect(200)
.expect('Content-Type', /image/);
});
});
describe('when trying to get a non-existing file', () => {
it('should return index page', async () => {
return request(server)
.get('/404')
.expect(200)
.expect('Content-Type', /html/)
.expect(/Static website/);
});
});
afterAll(async () => {
await app.close();
});
});
describe('when "fallthrough" option is set to "false"', () => {
beforeAll(async () => {
app = await NestFactory.create(AppModule.withoutFallthrough(), {
logger: new NoopLogger()
});
app.setGlobalPrefix('api');
server = app.getHttpServer();
await app.init();
});
describe('GET /api', () => {
it('should return "Hello, world!"', async () => {
return request(server).get('/api').expect(200).expect('Hello, world!');
});
});
describe('GET /', () => {
it('should return HTML file', async () => {
return request(server)
.get('/')
.expect(200)
.expect('Content-Type', /html/);
});
});
describe('GET /index.html', () => {
it('should return index page', async () => {
return request(server)
.get('/index.html')
.expect(200)
.expect('Content-Type', /html/)
.expect(/Static website/);
});
});
describe('GET /logo.svg', () => {
it('should return logo', async () => {
return request(server)
.get('/logo.svg')
.expect(200)
.expect('Content-Type', /image/);
});
});
describe('when trying to get a non-existing file', () => {
it('should return 404', async () => {
return request(server)
.get('/404')
.expect(404)
.expect(/Not Found/)
.expect(/ENOENT/);
});
});
describe('when trying to hit a non-existing route under the excluded path', () => {
it('should return 404', async () => {
return request(server)
.get('/api/404')
.expect(404)
.expect(/Not Found/)
.expect(/Cannot GET \/api\/404/);
});
});
afterAll(async () => {
await app.close();
});
});
});

View File

@@ -0,0 +1,193 @@
import { NestFactory } from '@nestjs/core';
import {
FastifyAdapter,
NestFastifyApplication
} from '@nestjs/platform-fastify';
import { AppModule } from '../src/app.module';
import { NoopLogger } from '../utils/noop-logger';
import request from 'supertest';
describe('Fastify adapter', () => {
let app: NestFastifyApplication;
describe('when "fallthrough" option is set to "true"', () => {
beforeAll(async () => {
app = await NestFactory.create(
AppModule.withFallthrough(),
new FastifyAdapter(),
{
logger: new NoopLogger()
}
);
app.setGlobalPrefix('api');
await app.init();
await app.getHttpAdapter().getInstance().ready();
});
describe('GET /api', () => {
it('should return "Hello, world!"', async () => {
return app
.inject({
method: 'GET',
url: '/api'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.payload).toEqual('Hello, world!');
});
});
});
describe('GET /', () => {
it('should return HTML file', async () => {
return app
.inject({
method: 'GET',
url: '/'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.headers['content-type']).toMatch(/html/);
expect(result.payload).toContain('Static website');
});
});
});
describe('GET /index.html', () => {
it('should return index page', async () => {
return app
.inject({
method: 'GET',
url: '/index.html'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.payload).toContain('Static website');
});
});
});
describe('GET /logo.svg', () => {
it('should return logo', async () => {
return app
.inject({
method: 'GET',
url: '/logo.svg'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.headers['content-type']).toMatch(/image/);
});
});
});
describe('when trying to get a non-existing file', () => {
it('should returns index page', async () => {
return app
.inject({
method: 'GET',
url: '/404'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.payload).toContain('Static website');
});
});
});
afterAll(async () => {
await app.close();
});
});
describe('when "fallthrough" option is set to "false"', () => {
beforeAll(async () => {
app = await NestFactory.create(
AppModule.withoutFallthrough(),
new FastifyAdapter(),
{
logger: new NoopLogger()
}
);
app.setGlobalPrefix('api');
await app.init();
await app.getHttpAdapter().getInstance().ready();
});
describe('GET /api', () => {
it('should return "Hello, world!"', async () => {
return app
.inject({
method: 'GET',
url: '/api'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.payload).toEqual('Hello, world!');
});
});
});
describe('GET /', () => {
it('should return HTML file', async () => {
return app
.inject({
method: 'GET',
url: '/'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.headers['content-type']).toMatch(/html/);
expect(result.payload).toContain('Static website');
});
});
});
describe('GET /index.html', () => {
it('should return index page', async () => {
return app
.inject({
method: 'GET',
url: '/index.html'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.payload).toContain('Static website');
});
});
});
describe('GET /logo.svg', () => {
it('should return logo', async () => {
return app
.inject({
method: 'GET',
url: '/logo.svg'
})
.then((result) => {
expect(result.statusCode).toEqual(200);
expect(result.headers['content-type']).toMatch(/image/);
});
});
});
describe('when trying to get a non-existing file', () => {
it('should return 404', async () => {
return app
.inject({
method: 'GET',
url: '/404'
})
.then((result) => {
expect(result.statusCode).toEqual(404);
});
});
});
afterAll(async () => {
await app.close();
});
});
});

View File

@@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@@ -0,0 +1,9 @@
import { Controller, Get } from '@nestjs/common';
@Controller()
export class AppController {
@Get()
getHello() {
return 'Hello, world!';
}
}

View File

@@ -0,0 +1,51 @@
import { Module } from '@nestjs/common';
import { join } from 'path';
import { ServeStaticModule } from '../../lib';
import { AppController } from './app.controller';
@Module({
controllers: [AppController]
})
export class AppModule {
static withDefaults() {
return {
module: AppModule,
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
exclude: ['/api/{*any}']
})
]
};
}
static withFallthrough() {
return {
module: AppModule,
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
exclude: ['/api/{*any}'],
serveStaticOptions: {
fallthrough: true
}
})
]
};
}
static withoutFallthrough() {
return {
module: AppModule,
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
exclude: ['/api/{*any}'],
serveStaticOptions: {
fallthrough: false
}
})
]
};
}
}

11
node_modules/@nestjs/serve-static/tests/src/main.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule.withoutFallthrough());
app.setGlobalPrefix('api');
await app.listen(3000);
console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();

View File

@@ -0,0 +1,9 @@
import { ConsoleLogger } from '@nestjs/common';
export class NoopLogger extends ConsoleLogger {
error(message: any, trace?: string, context?: string) {}
warn(message: any, context?: string) {}
log(message: any, context?: string) {}
debug(message: any, context?: string) {}
verbose(message: any, context?: string) {}
}