Are you ready to dive into the world of web development? If you’re looking for a robust foundation to build your Node.js applications, you’ve come to the right place! This guide walks you through the process of setting up a boilerplate app using Node.js, Express.js, and TypeScript.
Contents
Global Requisites
Before we begin, ensure you have the following prerequisites installed:
- Node (>= 10.5.0)
- TypeScript Compiler (tsc >= 3.0.1)
- MongoDB (with Mongoose >= 3.6.2)
- Redis
App Structure
Here’s a simplified view of the app structure:
bash structure
dist
public
src
controllers
exception
interfaces
middlewares
models
providers
routes
services
views
.env
.gitignore
nodemon.json
package.json
README.md
tsconfig.json
tslint.json
Think of the app structure like the blueprint of a house, where each section (controllers, models, etc.) serves a specific purpose, much like rooms in a home. The controllers
might be seen as your living rooms, direct traffic and interaction, while models
are like the foundation that holds everything together.
Install, Configure & Run
Follow these steps to install and set up your project:
# Clone the repo
git clone https://github.com/GeekyAnts/express-typescript.git;
# Go to the cloned project folder
cd express-typescript;
# Without Docker
# Ensure that MongoDB is running
npm install; # Install NPM dependencies
vim .env; # Edit .env file to configure application details
npm run dev; # Run the app
# With Docker
docker-compose up; # Run app as a foreground process
docker-compose up -d; # Run app as a background process
By following these commands, you’re essentially laying down the groundwork and then gradually building up the walls of your application, making sure everything is in place before the roof goes on.
List of Routes
The application provides multiple routes for web and API interactions:
Web Routes:
+--------+-------------------------+
| Method | URI |
+--------+-------------------------+
| GET | signup |
| POST | signup |
| GET | login |
| POST | login |
| GET | logout |
| GET | account |
| GET | auth/google |
| GET | auth/google/callback |
| GET | auth/twitter |
| GET | auth/twitter/callback |
| GET | status-monitor |
+--------+-------------------------+
API Routes:
+--------+-------------------------+
| Method | URI |
+--------+-------------------------+
| POST | api |
| POST | api/auth/login |
| POST | api/auth/register |
| POST | api/auth/refresh-token |
+--------+-------------------------+
Screens
The app provides several screens for user interaction:
- Home Landing Page
- LogIn Page
- SignUp Page
- Dashboard Page
- Page Not Found
- Under Maintenance Page
Troubleshooting
If you encounter any issues during setup or while running the application, here are some troubleshooting steps:
- Ensure all environment variables in your
.env
file are correctly configured. - Check if MongoDB is running properly.
- Make sure you have all the necessary Node modules installed by running
npm install
. - If you’re using Docker, check the Docker logs for errors.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.