Initial commit - Event Planner application
This commit is contained in:
7
node_modules/@nestjs/serve-static/tests/client/index.html
generated
vendored
Normal file
7
node_modules/@nestjs/serve-static/tests/client/index.html
generated
vendored
Normal 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>
|
||||
43
node_modules/@nestjs/serve-static/tests/client/logo.svg
generated
vendored
Normal file
43
node_modules/@nestjs/serve-static/tests/client/logo.svg
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 14 KiB |
159
node_modules/@nestjs/serve-static/tests/e2e/express-adapter.e2e-spec.ts
generated
vendored
Normal file
159
node_modules/@nestjs/serve-static/tests/e2e/express-adapter.e2e-spec.ts
generated
vendored
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
193
node_modules/@nestjs/serve-static/tests/e2e/fastify-adapter.e2e-spec.ts
generated
vendored
Normal file
193
node_modules/@nestjs/serve-static/tests/e2e/fastify-adapter.e2e-spec.ts
generated
vendored
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
9
node_modules/@nestjs/serve-static/tests/jest-e2e.json
generated
vendored
Normal file
9
node_modules/@nestjs/serve-static/tests/jest-e2e.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
9
node_modules/@nestjs/serve-static/tests/src/app.controller.ts
generated
vendored
Normal file
9
node_modules/@nestjs/serve-static/tests/src/app.controller.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
@Get()
|
||||
getHello() {
|
||||
return 'Hello, world!';
|
||||
}
|
||||
}
|
||||
51
node_modules/@nestjs/serve-static/tests/src/app.module.ts
generated
vendored
Normal file
51
node_modules/@nestjs/serve-static/tests/src/app.module.ts
generated
vendored
Normal 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
11
node_modules/@nestjs/serve-static/tests/src/main.ts
generated
vendored
Normal 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();
|
||||
9
node_modules/@nestjs/serve-static/tests/utils/noop-logger.ts
generated
vendored
Normal file
9
node_modules/@nestjs/serve-static/tests/utils/noop-logger.ts
generated
vendored
Normal 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) {}
|
||||
}
|
||||
Reference in New Issue
Block a user