Express Routing

PHOTO EMBED

Sat Nov 28 2020 17:42:31 GMT+0000 (Coordinated Universal Time)

Saved by @robertjbass #typescript

//* Root Handler
app.get("/", (req, res) =>
  res.sendFile(path.join(__dirname + "/public/index.html"))
);

app.get('api/v1', (req,res) => res.json())

// Set static folder
app.use(express.static(path.join(__dirname, 'public')));

app.use('/api/v1', require('./routes/api/v1'))

app.listen(port, () => {
  console.log(`Server at: http://localhost:${port}`);
});
content_copyCOPY

NodeJS Express Routing