Skip to content

Commit

Permalink
Merge branch 'release/v0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Luphia1984 committed Mar 15, 2024
2 parents fb6233d + fd3c72a commit a035427
Show file tree
Hide file tree
Showing 314 changed files with 35,592 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
plugins: ['@typescript-eslint'],
},
],
extends: ['plugin:import/typescript', 'plugin:tailwindcss/recommended'],
extends: ['plugin:import/typescript', 'plugin:tailwindcss/recommended', 'next/core-web-vitals'],
// 加上 no console log 規則
rules: {
'no-console': 'error',
Expand Down
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: check-json
- id: check-xml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v4.0.0-alpha.8'
hooks:
- id: prettier
args: ['--config', '.prettierrc.yaml']
14 changes: 0 additions & 14 deletions .prettierrc

This file was deleted.

12 changes: 12 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
$schema: http://json.schemastore.org/prettierrc
arrowParens: avoid
bracketSpacing: false
jsxSingleQuote: false
printWidth: 100
proseWrap: always
quoteProps: preserve
semi: true
singleQuote: true
tabWidth: 2
trailingComma: es5
useTabs: false
127 changes: 108 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,123 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# BAIFA

## Getting Started
> 最後更新於 2024-01-16
First, run the development server:
## 部署流程

```bash
npm run dev
# or
yarn dev
1. [環境準備](#環境準備)
2. [管理帳號設定](#管理帳號設定)
3. [SWAP 設定](#swap-設定)
4. [執行環境準備](#執行環境準備)
5. [原始碼下載與編譯](#原始碼下載與編譯)
6. [最終檢查](#最終檢查)

### 環境準備

請確保您的系統滿足以下最低要求:

- Ubuntu 22.04
- 1 Core CPU
- 2 GB Ram
- 20 GB Disk Space

### 管理帳號設定

```shell
# 建立 BAIFA 帳號
useradd -m -s /usr/bin/bash baifa
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
```shell
# 設定 BAIFA 登入密碼
passwd baifa
New password:
```

You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
```shell
# 授權 BAIFA sudo 權限
sudo usermod -g sudo baifa
```

[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
### SWAP 設定

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
```shell
# 建立 swap 檔案
sudo fallocate -l 4G /swapfile
```

## Learn More
```shell
# 設定 swap 與開機啟動程序
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
```

### 執行環境準備

To learn more about Next.js, take a look at the following resources:
```shell
# 安裝必要函式庫
sudo apt-get update
sudo apt-get install openssl libtool autoconf automake uuid-dev build-essential gcc g++ software-properties-common unzip make git libcap2-bin -y
```

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
### Install Node

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
```shell
# 安裝 nodejs, pm2 並授予 80 443 port 權限
bash <(curl https://raw.githubusercontent.com/Luphia/SIMPLE/master/shell/install-env.sh -kL)
```

### 原始碼下載與編譯

```shell
# 資料夾建立與授權移轉
sudo mkdir /workspace
sudo chown baifa /workspace -R
```

## Deploy on Vercel
```shell
# 下載原始碼
cd /workspace
git clone https://github.com/CAFECA-IO/BAIFA
```

```shell
# 安裝函式庫
cd /workspace/BAIFA
npm install
```

```shell
# 設定環境參數
cp example.local.env .env.local
vi .env.local
```

```shell
# 編譯
npm run build
```

### 最終檢查

```shell
# 啟動專案
pm2 start npm --name BAIFA -- run production
```

```shell
# 檢視 log
pm2 log BAIFA
```

```shell
# 出現以下資訊即表示起動成功
▲ Next.js 14.0.4
- Local: http://localhost:80
```

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
## 聯繫我們

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
如果您對 BAIFA 感興趣或有任何疑問,請隨時聯繫我們的客戶支持團隊。我們期待著與您一起開啟更加先進、高
效的財務管理體驗,讓您的企業在數字時代更上一層樓。
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('jest').Config} */
const config = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'node',
modulePathIgnorePatterns: ['integration-test'],
};

module.exports = config;
11 changes: 11 additions & 0 deletions next-i18next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

const i18nConfig = {
i18n: {
defaultLocale: 'tw',
locales: ['tw', 'en', 'cn'],
},
localePath: path.resolve('./src/locales'),
};

module.exports = i18nConfig;
28 changes: 28 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
/** @type {import('next').NextConfig} */
const {i18n} = require('./next-i18next.config');

const nextConfig = {
async headers() {
return [
{
// matching all API routes
source: '/api/:path*',
headers: [
{key: 'Access-Control-Allow-Credentials', value: 'true'},
{key: 'Access-Control-Allow-Origin', value: '*'}, // replace this your actual origin
{key: 'Access-Control-Allow-Methods', value: 'GET,DELETE,PATCH,POST,PUT'},
{
key: 'Access-Control-Allow-Headers',
value:
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version',
},
],
},
];
},
reactStrictMode: true,
swcMinify: true,
i18n,
env: {
BAIFA_ADDRESS_IN_ENGLISH: process.env.REACT_APP_BAIFA_ADDRESS_IN_ENGLISH,
BAIFA_ADDRESS_IN_CHINESE: process.env.REACT_APP_BAIFA_ADDRESS_IN_CHINESE,
BAIFA_ADDRESS_ON_GOOGLE_MAP: process.env.REACT_APP_BAIFA_ADDRESS_ON_GOOGLE_MAP,
BAIFA_PHONE_NUMBER: process.env.REACT_APP_BAIFA_PHONE_NUMBER,
GITHUB_LINK: process.env.REACT_APP_GITHUB_LINK,
},
};

module.exports = nextConfig;
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "baifa",
"version": "0.1.0",
"version": "0.1.1",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand All @@ -13,10 +13,21 @@
"production": "next start -p 80"
},
"dependencies": {
"@prisma/client": "^5.8.1",
"bitcoin-address-validation": "^2.2.3",
"clsx": "^2.1.0",
"i18next": "^23.2.8",
"next": "13.4.5",
"next-i18next": "^14.0.0",
"nodemailer": "^6.9.4",
"prettier": "^2.8.8",
"react": "18.2.0",
"react-dom": "18.2.0"
"react-dom": "18.2.0",
"react-i18next": "^13.0.1",
"react-icons": "^4.10.1",
"react-usestateref": "^1.0.8",
"tailwind-merge": "^2.2.1",
"web3-validator": "^2.0.4"
},
"devDependencies": {
"@types/jest": "^29.5.2",
Expand All @@ -36,6 +47,7 @@
"lint-staged": "^13.2.2",
"postcss": "^8.4.24",
"prettier-plugin-tailwindcss": "^0.3.0",
"prisma": "^5.8.1",
"tailwindcss": "^3.3.2",
"ts-jest": "^29.1.0",
"typescript": "5.1.3"
Expand Down
15 changes: 15 additions & 0 deletions prisma/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {PrismaClient} from '@prisma/client';

const prismaClientSingleton = () => {
return new PrismaClient();
};

declare global {
var prisma: undefined | ReturnType<typeof prismaClientSingleton>;
}

const prisma = globalThis.prisma ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== 'production') globalThis.prisma = prisma;
Loading

0 comments on commit a035427

Please sign in to comment.