-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
314 changed files
with
35,592 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 感興趣或有任何疑問,請隨時聯繫我們的客戶支持團隊。我們期待著與您一起開啟更加先進、高 | ||
效的財務管理體驗,讓您的企業在數字時代更上一層樓。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.