feat(node): read the port from env

This commit is contained in:
Victor Savkin 2019-02-07 10:01:46 -05:00
parent 1bd0ab2a80
commit 6d661cf633
2 changed files with 4 additions and 3 deletions

View File

@ -11,7 +11,7 @@ app.get('/', (req, res) => {
res.send(`Welcome to <%= name %>!`);
});
const port = 3333;
const port = process.env.port || 3333;
app.listen(port, (err) => {
if (err) {
console.error(err);

View File

@ -9,8 +9,9 @@ import { AppModule } from './app/app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3333, () => {
console.log('Listening at http://localhost:3333');
const port = process.env.port || 3333;
await app.listen(port, () => {
console.log(`Listening at http://localhost:${port}`);
});
}