neonfuz / ark

An easiest web app template on top of nest, TypeORM, Next.js and Material UI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An easiest web app template on top of nest, TypeORM, Next.js and Material UI.

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 nest
  • User authentication - powered by Passport
  • Material UI design
  • Environment variables using dotenv

Technologies

  • Hot reloading for the developer experience :)
    • nodemon - Monitor for any changes in your node.js application and automatically restart the server
    • Next.js - The React Framework
  • Lang
  • 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
    • 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
    • Next.js - The React Framework
  • 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.

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 "arkuser" with password "arkark"
$ 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:

windows-build-tools
  • Run npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe as Administrator
PostgreSQL
> postgresql-11.1-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: arkuser
    • Definition Panel:
      • Password: arkark
    • Priviledges Panel:
      • Check all Yes
  • Right click Databases and Create > 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
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=arkuser
DB_PASSWORD=arkark
DB_DATABASE=arkdb
DB_SYNCHRONIZE=true

# App
PROTOCOL=http
HOST=localhost
PORT=4000
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`
$ 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'
    }
  }]
};

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
  • Database: auto synchronization with entities
  • Server: integration between nest and Next.js
  • UI: integration between Next.js and Material UI
  • UX: validation
  • API: JSON API routes
  • Auth: passport-local (email & password)
  • Auth: passport-github2 (GitHub login)
  • Auth: passport-twitter (Twitter login)
  • Feature: authentication
  • Feature: blogging
  • Test: unit tests
  • Test: e2e tests

Articles

About

An easiest web app template on top of nest, TypeORM, Next.js and Material UI.

License:MIT License


Languages

Language:TypeScript 98.3%Language:JavaScript 1.7%