Hey There! ๐
๐คพ that โญ๏ธ button if you like this boilerplate.
A boilerplate for Node.js App.
- This boilerplate is built using Express.js web framework, and have used Typescript Lang for writing the app's logic.
- It uses the Node.js's Cluster API, this helps us to take advantage of multi-core systems & to handle the load.
- For storing configuration into the
process.env
, DOTENV for Node.js is used. - For Database, this repo contains the use of Mongoose (ie. MongoDB object modeling for Node.js).
- For Cache, this repo contains the use of memory-cache (ie. A simple in-memory cache for node.js).
- For Routing, this repo contains the use of express-router & have distributed Routes into two files ie. Web Routes & API Routes. The web routes are using CSRF Token while the API routes are using JSON Web Token.
- For Strategies Authentication, this repo contains the use of the Passport.js. Passport.js is compatible with Express.js and is authentication middleware for Node.js.
- For Logging, this repo uses custom Log class built in middlewares folder, and it creates logs file by date & removes the log files after 'X' days (You can define that 'X' in .env file).
- For Exception handling, this repo contains two classes ie.
Handler
&NativeEvent
- To Log, use
Log.info('Your message should go here!')
. Other options for logging areLog.warn
,Log.error
&Log.custom
. - For views, this repo contains the use of PUG template engine.
- For background queues, this repo contains the use of Kue. For more detail on the same, please review the Queue class
- node (>= 10.5.0)
- tsc (>= 3.0.1)
- typescript (>= 3.0.1)
- mongoose (>= 3.6.2)
- redis
Note: I am mentioning only files/folders which you need to configure if required
โโโ dist
โโโ public
โโโ src
โ โโโ controllers
โ โ โโโ Api
โ โ โ โโโ Auth
โ โ โ โ โโโ Login.ts
โ โ โ โ โโโ RefreshToken.ts
โ โ โ โ โโโ Register.ts
โ โ โ โโโ Home.ts
โ โ โโโ Auth
โ โ โ โโโ Login.ts
โ โ โ โโโ Logout.ts
โ โ โ โโโ Register.ts
โ โ โ โโโ Social.ts
โ โ โโโ Account.ts
โ โ โโโ Home.ts
โ โโโ exception
โ โ โโโ Handler.ts
โ โ โโโ NativeEvent.ts
โ โโโ interfaces
โ โ โโโ models
โ โ โ โโโ user.ts
โ โ โโโ vendors
โ โ โโโ index.ts
โ โ โโโ INext.ts
โ โ โโโ IRequest.ts
โ โ โโโ IResponse.ts
โ โโโ middlewares
โ โ โโโ CORS.ts
โ โ โโโ CsrfToken.ts
โ โ โโโ Http.ts
โ โ โโโ Kernel.ts
โ โ โโโ Log.ts
โ โ โโโ Statics.ts
โ โ โโโ StatusMonitor.ts
โ โ โโโ View.ts
โ โโโ models
โ โ โโโ User.ts
โ โโโ providers
โ โ โโโ App.ts
โ โ โโโ Cache.ts
โ โ โโโ Database.ts
โ โ โโโ Express.ts
โ โ โโโ Locals.ts
โ โ โโโ Passport.ts
โ โ โโโ Queue.ts
โ โ โโโ Routes.ts
โ โโโ routes
โ โ โโโ Api.ts
โ โ โโโ Web.ts
โ โโโ services
โ โ โโโ strategies
โ โ โโโ Google.ts
โ โ โโโ Local.ts
โ โ โโโ Twitter.ts
โ โโโ index.ts
โโโ views
โ โโโ includes
โ โโโ modals
โ โโโ pages
โ โโโ partials
โ โโโ static
โ โ โโโ css/*.css
โ โ โโโ js/*.js
โ โโโ layout.pug
โโโ .env
โโโ .gitignore
โโโ nodemon.json
โโโ package.json
โโโ README.md
โโโ tsconfig.json
โโโ tslint.json
Below mentioned are the steps to install, configure & run in your platform/distributions.
Note: It is preassumed here that you have mongoose running in background & you have created the database.
# Clone the repo.
git clone https://github.com/faizahmedfarooqui/nodets.git;
# Goto the cloned project folder.
cd nodets;
# Install NPM dependencies.
# Note: You can review the list of dependencies from the below link.
# https://github.com/faizahmedfarooqui/nodets/network/dependencies
npm install;
# Edit your DotEnv file using any editor of your choice.
# Please Note: You should add all the configurations details
# or else default values will be used!
vim .env;
# Run the app
npm run dev;
# Web Routes:
+--------+-------------------------+
Method | URI
+--------+-------------------------+
GET | /
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
+--------+-------------------------+
Note: This page has sub-sections, like about-us, contact-us & portfolio
Note: LogIn with Providers
Note: SignUp with Providers
Note: In case, the requested URI does not exist, app shows this page
Note: In case, a error is generated so instead of plain error we show under maintenance page