-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3321 from nestjs/6.9.0
chore(): 6.9.0 minor release
- Loading branch information
Showing
35 changed files
with
2,212 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# dependencies | ||
/node_modules | ||
|
||
# IDE | ||
/.idea | ||
/.awcache | ||
/.vscode | ||
|
||
# misc | ||
npm-debug.log | ||
|
||
# example | ||
/quick-start | ||
|
||
# tests | ||
/test | ||
/coverage | ||
/.nyc_output | ||
|
||
# dist | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { ExpressAdapter } from '@nestjs/platform-express'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { expect } from 'chai'; | ||
import * as express from 'express'; | ||
import { AppModule } from '../src/app.module'; | ||
import { randomPort } from './utils'; | ||
|
||
describe('Get URL (Express Application)', () => { | ||
let testModule: TestingModule; | ||
let port: number; | ||
|
||
beforeEach(async () => { | ||
testModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
port = await randomPort(); | ||
}); | ||
|
||
it('should be able to get the IPv6 address', async () => { | ||
const app = testModule.createNestApplication(new ExpressAdapter(express())); | ||
await app.listen(port); | ||
expect(await app.getUrl()).to.be.eql(`http://[::1]:${port}`); | ||
await app.close(); | ||
}); | ||
it('should be able to get the IPv4 address', async () => { | ||
const app = testModule.createNestApplication(new ExpressAdapter(express())); | ||
await app.listen(port, '127.0.0.5'); | ||
expect(await app.getUrl()).to.be.eql(`http://127.0.0.5:${port}`); | ||
await app.close(); | ||
}); | ||
it('should return 127.0.0.1 for 0.0.0.0', async () => { | ||
const app = testModule.createNestApplication(new ExpressAdapter(express())); | ||
await app.listen(port, '0.0.0.0'); | ||
expect(await app.getUrl()).to.be.eql(`http://127.0.0.1:${port}`); | ||
await app.close(); | ||
}); | ||
it('should throw an error for calling getUrl before listen', async () => { | ||
const app = testModule.createNestApplication(new ExpressAdapter(express())); | ||
try { | ||
await app.getUrl(); | ||
} catch (err) { | ||
expect(err).to.be.eql( | ||
'app.listen() needs to be called before calling app.getUrl()', | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { FastifyAdapter } from '@nestjs/platform-fastify'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { expect } from 'chai'; | ||
import { AppModule } from '../src/app.module'; | ||
import { randomPort } from './utils'; | ||
|
||
describe('Get URL (Fastify Application)', () => { | ||
let testModule: TestingModule; | ||
let port: number; | ||
|
||
beforeEach(async () => { | ||
testModule = await Test.createTestingModule({ | ||
imports: [AppModule], | ||
}).compile(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
port = await randomPort(); | ||
}); | ||
|
||
it('should be able to get the IPv4 address', async () => { | ||
const app = testModule.createNestApplication(new FastifyAdapter()); | ||
await app.listen(port, '127.0.0.5'); | ||
expect(await app.getUrl()).to.be.eql(`http://127.0.0.5:${port}`); | ||
await app.close(); | ||
}); | ||
it('should return 127.0.0.1 for 0.0.0.0', async () => { | ||
const app = testModule.createNestApplication(new FastifyAdapter()); | ||
await app.listen(port, '0.0.0.0'); | ||
expect(await app.getUrl()).to.be.eql(`http://127.0.0.1:${port}`); | ||
await app.close(); | ||
}); | ||
it('should throw an error for calling getUrl before listen', async () => { | ||
const app = testModule.createNestApplication(new FastifyAdapter()); | ||
try { | ||
await app.getUrl(); | ||
} catch (err) { | ||
expect(err).to.be.eql( | ||
'app.listen() needs to be called before calling app.getUrl()', | ||
); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as net from 'net'; | ||
|
||
export let port: number; | ||
|
||
export async function randomPort(): Promise<number> { | ||
const server = net.createServer(); | ||
return new Promise((resolve, reject) => { | ||
if (port) { | ||
resolve(port); | ||
} | ||
server.listen(0, () => { | ||
port = (server.address() as net.AddressInfo).port; | ||
server.close(); | ||
resolve(port); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.