This commit is contained in:
Leandro Facchinetti 2020-03-18 20:17:55 -04:00
parent 4e49678250
commit 8bedda75d8
1 changed files with 22 additions and 26 deletions

View File

@ -13,12 +13,10 @@ import {
} from "./components";
import fs from "fs";
const webApp = express();
webApp.use(express.static("static"));
webApp.use(express.urlencoded({ extended: true }));
webApp.get("/", (req, res) =>
export const webServer = express()
.use(express.static("static"))
.use(express.urlencoded({ extended: true }))
.get("/", (req, res) =>
res.send(
renderHtml(
<Layout>
@ -26,9 +24,8 @@ webApp.get("/", (req, res) =>
</Layout>
)
)
);
webApp.post("/", (req, res) => {
)
.post("/", (req, res) => {
const inbox: Inbox = { name: req.body.name, token: newToken() };
fs.writeFileSync(feedPath(inbox.token), renderXml(Feed(inbox)));
res.send(
@ -38,6 +35,5 @@ webApp.post("/", (req, res) => {
</Layout>
)
);
});
export const webServer = webApp.listen(8443);
})
.listen(8443);