ark
ark copied to clipboard
An easiest authentication system on top of NestJS, TypeORM, NEXT.js(v9.3) and Material UI(v4).
An easiest authentication system on top of NestJS, TypeORM, NEXT.js (v9) and Material UI (v4).
Features
- Cross platform - Mac, Linux and Windows
- Database synchronization with entities - powered by TypeORM
- Server Side Rendering - powered by NEXT.js
- API server - powered by NestJS
- Authentication - powered by Passport
- Material UI design
Technologies
- Hot reloading for the developer experience :)
- ts-node-dev - Compiles your TS app and restarts when files are modified
- NEXT.js - The React Framework
- Lang
- TypeScript - Javascript that scales
- Database
- PostgreSQL - The World's Most Advanced Open Source Relational Database
- ORM (Object-relational mapping)
- TypeORM - ORM for TypeScript and JavaScript (ES7, ES6, ES5)
- Server
- Environment variables
- dotenv - Loads environment variables from .env for nodejs projects
- dotenv-webpack - A secure webpack plugin that supports dotenv and other environment variables and only exposes what you choose and use.
- User authentication
- Passport - Simple, unobtrusive authentication for Node.js
- UI framework
- React - A JavaScript library for building user interfaces
- NEXT.js - The React Framework
- Material UI - React components that implement Google's Material Design.
Setup
Database Setup
Ark uses PostgreSQL v11.
For Mac Users
# install postgresql@11
$ brew install postgresql@11
# if you want to start postgresql@11 in startup, try do this
$ brew services start postgresql@11
# [MUST] create user "arkuser" with password "arkpass"
$ createuser -P arkuser
# [MUST] create database "arkdb" owened by "arkuser"
$ createdb arkdb -O arkuser
For Windows Users
Python
Because Ark uses node.bcrypt.js, we need a Python:
- Download an installer at https://www.python.org/downloads/windows
- Install with "Add Python 3.X to PATH" checked
windows-build-tools
- Run
npm install --global --production windows-build-tools
from an elevated PowerShell or CMD.exe as Administrator
PostgreSQL
- Download an installer at https://www.postgresql.org/download/windows (v11)
- Run the installer with a flag
--install_runtimes 0
like this:
> postgresql-11.6-3-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
andCreate > Login/Group Role
-
General
Panel:-
Name
:arkuser
-
-
Definition
Panel:-
Password
:arkpass
-
-
Priviledges
Panel:- Check all
Yes
- Check all
-
- Right click
Databases
andCreate > Database
-
General
Tab:-
Database
:arkdb
-
Owner
:arkuser
-
-
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:
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=arkuser
DB_PASSWORD=arkpass
DB_DATABASE=arkdb
DB_SYNCHRONIZE=true
APP_PROTOCOL=http
APP_HOST=localhost
APP_PORT=4000
APP_SESSION_SECRET=ark
Production Deployment
With production usages, please use pm2 for Node.js process managements.
# install pm2
$ npm install --global pm2
# run the app "ARK" with the config `ecosystem.config.js`
$ cd ark
$ pm2 start
The example ecosystem.config.js
:
module.exports = {
apps : [{
name: 'ARK',
script: '.next/production-server/main.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production'
}
}]
};
Screenshots
Register Page
Login Page
Top Page (Auth Guard)
Articles
Related
- YARK - Yet another easiest authentication system on top of NestJS, TypeORM, react-ssr and Material UI(v4)