Nest.js, TypeORM, GraphQL, LDAP Service, Passport, Next.js (v9), React.js, Material UI (v4)
- Cross platform - Mac, Linux and Windows
- API server - powered by Nest
- Environment variables using dotenv
- Server Side Rendering - powered by Next.js
- Material UI design
- TypeORM
- GraphQL
- React.js
- User authentication - powered by Passport
- LDAP through custom NestJS LDAPService
- WebSockets
- Hot reloading for the developer experience
- Next.js - The React Framework
- Lang
- TypeScript - Javascript that scales
- Linters
- ESLint - A fully pluggable tool for identifying and reporting on patterns in JavaScript
- Tests
- Jest - Delightful JavaScript Testing
- Enzyme - JavaScript Testing utilities for React
- @material-ui/core/test-utils
- @nestjs/testing - unit testing, e2e testing
- Supertest - for e2e testing
- Server
- nest - A progressive Node.js framework for building efficient, reliable and scalable server-side applications
- internally using Express - Fast, unopinionated, minimalist web framework for Node.js
- Nest.JS WebSockets
- Next.js - The React Framework
- nest - A progressive Node.js framework for building efficient, reliable and scalable server-side applications
- 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
- 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
Portal uses PostgreSQL.
- Install PostgreSQL 10 to your system.
- Add the bin directory of your postgresql installation to your PATH system environment variable. Warning! It must be system env, not user env!
- Make sure you have the latest npm installed.
- 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.)
# 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
- Download an installer at https://www.postgresql.org/download/windows
- Run the installer with a flag
--install_runtimes 0
like this:
> postgresql-11.2-1-windows-x64.exe --install_runtimes 0
- Download a latest installer at https://www.pgadmin.org/download
- Run the pgAdmin and login with a root user
- Right click
Login/Group Roles
andCreate > Login/Group Role
General
Panel:Name
:portal
Definition
Panel:Password
:portalpwd
- Right click
Databases
andCreate > Database
General
Tab:Database
:portaldb
Owner
:portal
# 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:[email protected]:5432/postgres"
DATABASE_URI_RD="postgres://postgres:[email protected]: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/"
We use Kubernetes/Docker production.
- 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