Skip to content

Commit

Permalink
Serve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
peimelo committed Jul 17, 2020
1 parent 500cbfa commit 16c239f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
// importa express
const express = require("express");

// inicia express
const app = express();

// nome da pasta dentro de dist que sera feito build, ver angular.json
const appName = "curso-angular-basico";

// local onde build ira gerar os arquivos
const outputPath = `${__dirname}/dist/${appName}`;

// seta o diretorio de build para servir o conteudo estatico
app.use(express.static(outputPath));

// qualquer requisicao sera direcionada para o index.html no diretorio de build
app.get("/documentation", (req, res) => {
res.sendFile(`${__dirname}/documentation/index.html`);
});

// qualquer requisicao sera direcionada para o index.html no diretorio de build
app.get("/*", (req, res) => {
res.sendFile(`${outputPath}/index.html`);
});

// express vai ouvir na porta que o Heroku disponibilizar
app.listen(process.env.PORT);

0 comments on commit 16c239f

Please sign in to comment.