GithubHelp home page GithubHelp logo

5l1v3r1 / express-typescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geekyants/express-typescript

0.0 1.0 0.0 990 KB

Express + TypeScript + Boilerplate for Web / API App

Home Page: https://geekyants.github.io/express-typescript/

License: MIT License

TypeScript 58.54% HTML 29.59% CSS 8.81% JavaScript 3.06%

express-typescript's Introduction

Hey There! ๐Ÿ™Œ 
๐Ÿคพ that โญ๏ธ button if you like this boilerplate. 

express-typescript

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 are Log.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

Contents

Global Requisites

  • node (>= 10.5.0)
  • tsc (>= 3.0.1)
  • typescript (>= 3.0.1)
  • mongoose (>= 3.6.2)
  • redis

App Structure

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

Install, Configure & Run

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/GeekyAnts/express-typescript.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;

List of Routes

# 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
+--------+-------------------------+

Screens

Home / Landing Page

Home / Landing Page

Note: This page has sub-sections, like about-us, contact-us & portfolio

LogIn Page

LogIn Page

Note: LogIn with Providers

SignUp Page

SignUp Page

Note: SignUp with Providers

Dashboard Page

Dashboard Page

With Dropdown Menu

Dashboard Page with Dropdown Menu

Page Not Found Page

Page Not Found Page

Note: In case the requested URI does not exist, app shows this page

Under Maintenance Page

Under Maintenance Page

Note: In case an error is generated, so instead of plain errors we can show the under maintenance page.

express-typescript's People

Contributors

faizahmedfarooqui avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.