基于NestJS,TypeORM,NEXT.js(v9)和Material UI(v4)的最简单的身份验证系统。
方舟使用PostgreSQL v11。
# 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
由于Ark使用node.bcrypt.js,因此我们需要一个Python:
npm install --global --production windows-build-tools从提升的PowerShell或CMD.exe运行
--install_runtimes 0:
> postgresql-11.6-3-windows-x64.exe --install_runtimes 0
Login/Group Roles并
Create > Login/Group Role
General面板:
Name:
arkuser
Definition面板:
Password:
arkpass
Priviledges面板:
Yes
Databases并
Create > Database
General标签:
Database:
arkdb
Owner:
arkuser
# 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
该
.env文件是这样的:
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
对于生产用途,请使用pm2进行Node.js流程管理。
# install pm2
$ npm install --global pm2
# run the app "ARK" with the config `ecosystem.config.js`
$ cd ark
$ pm2 start
例子
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'
}
}]
};