DEV Community

Discussion on: How I structure my Express + Typescript + React applications

Collapse
 
leejjon_net profile image
Leejjon • Edited

Great article, I'm using a similar approach to host my blindpool.com app on Google App Engine with node.js. This tutorial will help me convert it to TypeScript without having to Google every step :)

One thing though, at the point where you tell the user to add this:

this.app.use(express.static(path.resolve("./") + "/build/frontend"));

this.app.get("/api", (req: Request, res: Response): void => {
   res.send("You have reached the API!");
});

this.app.get("*", (req: Request, res: Response): void => {
   res.sendFile(path.resolve("./") + "/build/frontend/index.html");
});

Maybe also inform they have to add the imports:

import express from "express";
import * as path from "path";

I had to look them up from your github project.