wisekaa03 / portal

Nest.js, TypeORM, GraphQL, LDAP Service, Passport, Next.js (v10), React.js, Material UI (v4)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Portal

Nest.js, TypeORM, GraphQL, LDAP Service, Passport, Next.js (v9), React.js, Material UI (v4)

Features

Technologies

  • Hot reloading for the developer experience
  • Lang
  • Linters
    • ESLint - A fully pluggable tool for identifying and reporting on patterns in JavaScript
  • Tests
  • Server
    • nest - A progressive Node.js framework for building efficient, reliable and scalable server-side applications
    • Next.js - The React Framework
  • Environment variables
    • dotenv - Loads environment variables from .env for nodejs projects
  • Database
    • PostgreSQL - The World's Most Advanced Open Source Relational Database
    • TypeORM - TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8)
    • GraphQL - Create a GraphQL HTTP server with Express
  • User authentication
    • LDAP - NestJS LDAP Service, internally using ldapjs
    • Passport - Simple, unobtrusive authentication for Node.js
  • UI framework
    • Next.js - The React Framework
    • React - A JavaScript library for building user interfaces
    • Apollo GraphQL - A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server
    • Material UI - React components that implement Google's Material Design.
  • WebSockets
    • subscription

Setup

Database Setup

Portal uses PostgreSQL.

For Windows Users

  1. Install PostgreSQL 10 to your system.
  2. Add the bin directory of your postgresql installation to your PATH system environment variable. Warning! It must be system env, not user env!
  3. Make sure you have the latest npm installed.
  4. Start a new elevated shell (cmd.exe or powershell). E.g. "run as administrator". If you did not restart your system after step 2, then make sure that you can run the "pg_config" program from that shell. run the commands below, in this order, in the same terminal. do not close and reopen the terminal between two commands!
npm install --global --production windows-build-tools
npm install -g node-gyp
npm install -g pg-native

Please note that installing node-gyp requires admin rights, so you must install it globally as admin, even if you only need it for one project. (I might be wrong, but this was my experience.)

For Mac Users

# install postgresql
$ brew install postgresql

# if you want to start postgresql in startup, try do this
$ brew services start postgresql

# [MUST] create user "portal"
$ createuser -P -l portal

# [MUST] create database "portal" owened by "portal"
$ createdb portal -O portaldb

PostgreSQL

> postgresql-11.2-1-windows-x64.exe --install_runtimes 0

pgAdmin

  • Download a latest installer at https://www.pgadmin.org/download
  • Run the pgAdmin and login with a root user
  • Right click Login/Group Roles and Create > Login/Group Role
    • General Panel:
      • Name: portal
    • Definition Panel:
      • Password: portalpwd
  • Right click Databases and Create > Database
    • General Tab:
      • Database: portaldb
      • Owner: portal

Application Setup

# prepare `.env` and edit it for your own environments
$ cp .env.example .env

# install dependencies
$ yarn

# development mode
$ yarn dev

# production mode
$ yarn build
$ yarn start

The .env file is like this:

# App
PORT=4000
DOMAIN="example.com"
DEVELOPMENT="true"

# Logging
LOG_LEVEL="debug"
LOG_SERVER="gelf://graylog-udp.monitoring:12201?facility=local0&bufferSize=1400&deflate=optimal"

# DB
DATABASE_URI="postgres://postgres:1234567890@postgresql.database:5432/postgres"
DATABASE_URI_RD="postgres://postgres:1234567890@postgresql-read.database:5432/postgres"
DATABASE_SCHEMA="public"
DATABASE_SYNCHRONIZE="false"
DATABASE_DROP_SCHEMA="false"
DATABASE_MIGRATIONS_RUN="true"
DATABASE_LOGGING=["error"]
DATABASE_REDIS_URI="redis://redis-master.production.svc.cluster.local:6379/0"
# time in milliseconds, 3000 ms = 3 seconds
DATABASE_REDIS_TTL="3000"

# HTTP Redis
HTTP_REDIS_URI="redis://localhost:6379/1"
# time in milliseconds, 600000 ms = 1000 * 60 * 10 minutes
HTTP_REDIS_TTL="300"
HTTP_REDIS_MAX_OBJECTS="10000"

# Session Redis
SESSION_REDIS_URI="redis://redis-master.production.svc.cluster.local:6379/2"
# time in milliseconds, 1200000 ms = 1000 * 60 * 20 minutes
SESSION_COOKIE_TTL="1200000"
SESSION_SECRET="supersecret"

# LDAP
LDAP={"example.com": {"url":"ldaps://pdc.example.local:389", "bindDn":"CN=Administrator,DC=example,DC=local", "bindPw":"PaSsWoRd123", "searchBase":"DC=example,DC=local", "searchUser":, "searchGroup":"(&(objectClass=group)(member={{dn}}))", "searchAllUsers":"(&(&(|(&(objectClass=user)(objectCategory=person))(&(objectClass=contact)(objectCategory=person)))))", "searchAllGroups":"objectClass=group", "newBase":"OU=User,DC=example,DC=local"}}

# LDAP Redis
LDAP_REDIS_URI="redis://localhost:6379/3"
# time in milliseconds, 600000 ms = 1000 * 60 * 10 minutes
LDAP_REDIS_TTL="300"

# MICROSERVICE
MICROSERVICE_URL="redis://localhost:6379"

# SOAP
TICKETS_URL="https://server1c"
TICKETS_REDIS_URI="redis://localhost:6379/5"
TICKETS_REDIS_TTL="60"
REPORTS_URL="https://server1c"
REPORTS_REDIS_URI="redis://localhost:6379/6"
REPORTS_REDIS_TTL="60"
DOCFLOW_URL="https://server1c"
DOCFLOW_REDIS_URI="redis://localhost:6379/7"
DOCFLOW_REDIS_TTL="60"

# OSTICKET
OSTICKET_URL={"auditors": "https://auditors-ticket.example.com/au/portal/ajax.php", "media": "https://media-ticket.example.com/mp/portal/ajax.php"}

# NEXTCLOUD
NEXTCLOUD_URL="https://cloud.example.com"
NEXTCLOUD_REDIS_URI="redis://localhost:6379/4"
NEXTCLOUD_REDIS_TTL="60"

# NEWS
NEWS_URL="https://news/wp/wp-json/wp/v2/posts"
NEWS_API_URL="https://news/wp/wp-content/"

# MAIL
MAIL_URL="https://portal/roundcube"
MAIL_LOGIN_URL="/roundcube/login/index.php"

# MEETING
MEETING_URL="https://meeting/"

Production Deployment

We use Kubernetes/Docker production.

Roadmaps

  • Support: Mac, Linux and Windows
  • Support: production usages
  • Security: environment variables both server and client
  • Security: production ready session store
  • Security: custom auth guards
  • Server: integration between Nest and Next.js
  • UI: integration between Next.js and Material UI
  • Authentication with LDAP
  • Test: unit tests
  • [-] Test: e2e tests
  • Nest.JS WebSockets
  • Apollo Link WebSockets

About

Nest.js, TypeORM, GraphQL, LDAP Service, Passport, Next.js (v10), React.js, Material UI (v4)

License:MIT License


Languages

Language:TypeScript 95.4%Language:JavaScript 3.5%Language:Shell 0.5%Language:Mustache 0.5%Language:Dockerfile 0.1%Language:HTML 0.0%