Building pugia.com ~ adding some structure

Folder tree, server, about route and Pug template
// find routes in routes folder
const routes = fs.readdirSync(SRC_PATH + 'routes/');
for (var x in routes) {
if (routes.hasOwnProperty(x)) {
const route = path.basename(routes[x], '.js');
if (route === 'index') {
app.use('/', require('./src/routes/index'));
} else {
app.use('/' + route, require('./src/routes/' + route));
}
}
}

--

--

--

CTO @ Nibol

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Marco Pugliese

Marco Pugliese

CTO @ Nibol

More from Medium

How do we build the backend and connect it with the frontend

Using Cypress Intercept to Fix a Cross-Domain Test

Why Should You Use Node JS ?

Introduction and summarize about NoSql