diff --git a/.github/workflows/backend-dev-preview.yml b/.github/workflows/backend-dev-preview.yml new file mode 100644 index 00000000..e277b73e --- /dev/null +++ b/.github/workflows/backend-dev-preview.yml @@ -0,0 +1,24 @@ +name: Backend - Deploy (Development Preview) +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_DEV_ID }} +on: + push: + paths: + - 'backend/**' + +jobs: + Deploy-Development-Preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@canary + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Javascript Files + run: npm run build + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/backend-dev.yml b/.github/workflows/backend-dev.yml new file mode 100644 index 00000000..9df95744 --- /dev/null +++ b/.github/workflows/backend-dev.yml @@ -0,0 +1,26 @@ +name: Backend - Deploy (Development) +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_DEV_ID }} +on: + push: + branches: + - dev + paths: + - 'backend/**' + +jobs: + Deploy-Development: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@canary + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Javascript Files + run: npm run build + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/backend-prod.yml b/.github/workflows/backend-prod.yml new file mode 100644 index 00000000..87b84022 --- /dev/null +++ b/.github/workflows/backend-prod.yml @@ -0,0 +1,26 @@ +name: Backend - Deploy (Production) +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BACKEND_DEV_ID }} +on: + push: + branches: + - main + paths: + - 'backend/**' + +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@canary + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Javascript Files + run: npm run build + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/types-publish.yml b/.github/workflows/types-publish.yml new file mode 100644 index 00000000..229b916c --- /dev/null +++ b/.github/workflows/types-publish.yml @@ -0,0 +1,24 @@ +name: Types - Publish to npm + +on: + push: + branches: + - main + paths: + - 'types/**' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + - name: Install Dependencies + run: npm ci + - name: Build package artifacts + run: npm run build + - name: Publish to npm + run: npm publish --access public diff --git a/.gitignore b/.gitignore index c42e25dd..8cda4828 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .idea +*/.env.* */.env +!*/.env.example */node_modules ### JetBrains ### @@ -138,7 +140,7 @@ yarn-error.log* .pnpm-debug.log* # local env files -.env*.local +*/.env.* # vercel .vercel diff --git a/aapc-backend/.gitignore b/backend/.gitignore similarity index 95% rename from aapc-backend/.gitignore rename to backend/.gitignore index 53f1d342..57f7d40b 100644 --- a/aapc-backend/.gitignore +++ b/backend/.gitignore @@ -19,3 +19,4 @@ # typescript *.tsbuildinfo next-env.d.ts +.vercel diff --git a/backend/.vercelignore b/backend/.vercelignore new file mode 100644 index 00000000..3615120b --- /dev/null +++ b/backend/.vercelignore @@ -0,0 +1 @@ +.env.* diff --git a/aapc-backend/README.md b/backend/README.md similarity index 100% rename from aapc-backend/README.md rename to backend/README.md diff --git a/aapc-backend/package-lock.json b/backend/package-lock.json similarity index 99% rename from aapc-backend/package-lock.json rename to backend/package-lock.json index 82b1d1a9..119f0228 100644 --- a/aapc-backend/package-lock.json +++ b/backend/package-lock.json @@ -8,6 +8,7 @@ "name": "aapc-backend", "version": "0.1.1", "dependencies": { + "@aapc/types": "^0.2.0", "dotenv": "^16.4.5", "express": "^4.19.2", "mongodb": "^6.5.0" @@ -15,20 +16,15 @@ "devDependencies": { "@types/express": "^4.17.21", "@types/node": "^20.12.2", - "aapc-types": "file:../aapc-types", "nodemon": "^3.1.0", "tsx": "^4.7.1", "typescript": "^5.4.3" } }, - "../aapc-types": { - "version": "0.1.0", - "dev": true, - "devDependencies": { - "@vitest/coverage-v8": "^1.4.0", - "typescript": "^5.4.3", - "vitest": "^1.4.0" - } + "node_modules/@aapc/types": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@aapc/types/-/types-0.2.0.tgz", + "integrity": "sha512-Eh/6+7G4I2yvgsItDls6PQrUyPw/qT76HEXTkI08IJ9zi3Sucb9aZTSqQCmWDMZrhbi/k/xXc0gte/TLVfgGXQ==" }, "node_modules/@esbuild/aix-ppc64": { "version": "0.19.12", @@ -516,10 +512,6 @@ "@types/webidl-conversions": "*" } }, - "node_modules/aapc-types": { - "resolved": "../aapc-types", - "link": true - }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", diff --git a/aapc-backend/package.json b/backend/package.json similarity index 59% rename from aapc-backend/package.json rename to backend/package.json index aa08f9b9..d4d9266c 100644 --- a/aapc-backend/package.json +++ b/backend/package.json @@ -4,11 +4,14 @@ "private": true, "description": "The backend of the AAPC website.", "scripts": { - "dev": "nodemon -x tsx src/index.ts", + "dev": "nodemon -x tsx ./src/index.ts", "build": "tsc --build", - "start": "tsc --build && node ./dist/index.js" + "start": "node ./dist/index.js", + "deploy:development": "npm run build && vercel build && vercel deploy --prebuilt", + "deploy:production": "npm run build && vercel build --prod && vercel --prod deploy --prebuilt" }, "dependencies": { + "@aapc/types": "^0.2.0", "dotenv": "^16.4.5", "express": "^4.19.2", "mongodb": "^6.5.0" @@ -16,7 +19,6 @@ "devDependencies": { "@types/express": "^4.17.21", "@types/node": "^20.12.2", - "aapc-types": "file:../aapc-types", "nodemon": "^3.1.0", "tsx": "^4.7.1", "typescript": "^5.4.3" diff --git a/aapc-backend/src/config/mongo.config.ts b/backend/src/config/mongo.config.ts similarity index 100% rename from aapc-backend/src/config/mongo.config.ts rename to backend/src/config/mongo.config.ts diff --git a/aapc-backend/src/controllers/news.controller.ts b/backend/src/controllers/news.controller.ts similarity index 100% rename from aapc-backend/src/controllers/news.controller.ts rename to backend/src/controllers/news.controller.ts diff --git a/aapc-backend/src/controllers/research.controller.ts b/backend/src/controllers/research.controller.ts similarity index 100% rename from aapc-backend/src/controllers/research.controller.ts rename to backend/src/controllers/research.controller.ts diff --git a/aapc-backend/src/index.ts b/backend/src/index.ts similarity index 100% rename from aapc-backend/src/index.ts rename to backend/src/index.ts diff --git a/aapc-backend/src/repositories/IRepository.ts b/backend/src/repositories/IRepository.ts similarity index 89% rename from aapc-backend/src/repositories/IRepository.ts rename to backend/src/repositories/IRepository.ts index 64b11dd1..6ee5632f 100644 --- a/aapc-backend/src/repositories/IRepository.ts +++ b/backend/src/repositories/IRepository.ts @@ -1,4 +1,4 @@ -import { Article, User } from "aapc-types"; +import { Article, User } from "@aapc/types"; import { Nullable } from "../util/types"; export default interface IRepository { diff --git a/aapc-backend/src/repositories/memory/MemoryRepository.ts b/backend/src/repositories/memory/MemoryRepository.ts similarity index 95% rename from aapc-backend/src/repositories/memory/MemoryRepository.ts rename to backend/src/repositories/memory/MemoryRepository.ts index b98c96f0..ad5ce3b0 100644 --- a/aapc-backend/src/repositories/memory/MemoryRepository.ts +++ b/backend/src/repositories/memory/MemoryRepository.ts @@ -1,9 +1,8 @@ -import { Article, User } from "aapc-types"; +import { Article, User, IArticle } from "@aapc/types"; import IRepository from "../IRepository"; import users from "./data/users.json" import news from "./data/news.json" import researches from "./data/researches.json" -import { IArticle } from "aapc-types/src/Article"; import { Nullable } from "../../util/types"; export default class MemoryRepository implements IRepository { diff --git a/aapc-backend/src/repositories/memory/data/news.json b/backend/src/repositories/memory/data/news.json similarity index 100% rename from aapc-backend/src/repositories/memory/data/news.json rename to backend/src/repositories/memory/data/news.json diff --git a/aapc-backend/src/repositories/memory/data/researches.json b/backend/src/repositories/memory/data/researches.json similarity index 100% rename from aapc-backend/src/repositories/memory/data/researches.json rename to backend/src/repositories/memory/data/researches.json diff --git a/aapc-backend/src/repositories/memory/data/users.json b/backend/src/repositories/memory/data/users.json similarity index 100% rename from aapc-backend/src/repositories/memory/data/users.json rename to backend/src/repositories/memory/data/users.json diff --git a/aapc-backend/src/repositories/repository.ts b/backend/src/repositories/repository.ts similarity index 100% rename from aapc-backend/src/repositories/repository.ts rename to backend/src/repositories/repository.ts diff --git a/aapc-backend/src/routes/news.router.ts b/backend/src/routes/news.router.ts similarity index 100% rename from aapc-backend/src/routes/news.router.ts rename to backend/src/routes/news.router.ts diff --git a/aapc-backend/src/routes/research.router.ts b/backend/src/routes/research.router.ts similarity index 100% rename from aapc-backend/src/routes/research.router.ts rename to backend/src/routes/research.router.ts diff --git a/aapc-backend/src/util/types.ts b/backend/src/util/types.ts similarity index 100% rename from aapc-backend/src/util/types.ts rename to backend/src/util/types.ts diff --git a/aapc-backend/tsconfig.json b/backend/tsconfig.json similarity index 100% rename from aapc-backend/tsconfig.json rename to backend/tsconfig.json diff --git a/backend/vercel.json b/backend/vercel.json new file mode 100644 index 00000000..ae833786 --- /dev/null +++ b/backend/vercel.json @@ -0,0 +1,14 @@ +{ + "builds": [ + { + "src": "dist/index.js", + "use": "@vercel/node" + } + ], + "rewrites": [ + { + "source": "/(.*)", + "destination": "dist/index.js" + } + ] +} \ No newline at end of file diff --git a/aapc-frontend/.eslintrc.json b/frontend/.eslintrc.json similarity index 100% rename from aapc-frontend/.eslintrc.json rename to frontend/.eslintrc.json diff --git a/aapc-frontend/.gitignore b/frontend/.gitignore similarity index 100% rename from aapc-frontend/.gitignore rename to frontend/.gitignore diff --git a/aapc-frontend/README.md b/frontend/README.md similarity index 100% rename from aapc-frontend/README.md rename to frontend/README.md diff --git a/aapc-frontend/app/(cms)/layout.tsx b/frontend/app/(cms)/layout.tsx similarity index 100% rename from aapc-frontend/app/(cms)/layout.tsx rename to frontend/app/(cms)/layout.tsx diff --git a/aapc-frontend/app/(cms)/news/[id]/edit/page.tsx b/frontend/app/(cms)/news/[id]/edit/page.tsx similarity index 100% rename from aapc-frontend/app/(cms)/news/[id]/edit/page.tsx rename to frontend/app/(cms)/news/[id]/edit/page.tsx diff --git a/aapc-frontend/app/(cms)/news/create/page.tsx b/frontend/app/(cms)/news/create/page.tsx similarity index 100% rename from aapc-frontend/app/(cms)/news/create/page.tsx rename to frontend/app/(cms)/news/create/page.tsx diff --git a/aapc-frontend/app/(cms)/research/[id]/edit/page.tsx b/frontend/app/(cms)/research/[id]/edit/page.tsx similarity index 100% rename from aapc-frontend/app/(cms)/research/[id]/edit/page.tsx rename to frontend/app/(cms)/research/[id]/edit/page.tsx diff --git a/aapc-frontend/app/(cms)/research/create/page.tsx b/frontend/app/(cms)/research/create/page.tsx similarity index 100% rename from aapc-frontend/app/(cms)/research/create/page.tsx rename to frontend/app/(cms)/research/create/page.tsx diff --git a/aapc-frontend/app/(content)/about/page.tsx b/frontend/app/(content)/about/page.tsx similarity index 100% rename from aapc-frontend/app/(content)/about/page.tsx rename to frontend/app/(content)/about/page.tsx diff --git a/aapc-frontend/app/(content)/layout.tsx b/frontend/app/(content)/layout.tsx similarity index 100% rename from aapc-frontend/app/(content)/layout.tsx rename to frontend/app/(content)/layout.tsx diff --git a/aapc-frontend/app/(content)/news/[id]/page.tsx b/frontend/app/(content)/news/[id]/page.tsx similarity index 100% rename from aapc-frontend/app/(content)/news/[id]/page.tsx rename to frontend/app/(content)/news/[id]/page.tsx diff --git a/aapc-frontend/app/(content)/research/[id]/page.tsx b/frontend/app/(content)/research/[id]/page.tsx similarity index 100% rename from aapc-frontend/app/(content)/research/[id]/page.tsx rename to frontend/app/(content)/research/[id]/page.tsx diff --git a/aapc-frontend/app/(homepage)/layout.tsx b/frontend/app/(homepage)/layout.tsx similarity index 100% rename from aapc-frontend/app/(homepage)/layout.tsx rename to frontend/app/(homepage)/layout.tsx diff --git a/aapc-frontend/app/(homepage)/page.tsx b/frontend/app/(homepage)/page.tsx similarity index 100% rename from aapc-frontend/app/(homepage)/page.tsx rename to frontend/app/(homepage)/page.tsx diff --git a/aapc-frontend/app/components/nav.tsx b/frontend/app/components/nav.tsx similarity index 100% rename from aapc-frontend/app/components/nav.tsx rename to frontend/app/components/nav.tsx diff --git a/aapc-frontend/app/globals.css b/frontend/app/globals.css similarity index 100% rename from aapc-frontend/app/globals.css rename to frontend/app/globals.css diff --git a/aapc-frontend/app/layout.tsx b/frontend/app/layout.tsx similarity index 100% rename from aapc-frontend/app/layout.tsx rename to frontend/app/layout.tsx diff --git a/aapc-frontend/next.config.mjs b/frontend/next.config.mjs similarity index 100% rename from aapc-frontend/next.config.mjs rename to frontend/next.config.mjs diff --git a/aapc-frontend/package-lock.json b/frontend/package-lock.json similarity index 100% rename from aapc-frontend/package-lock.json rename to frontend/package-lock.json diff --git a/aapc-frontend/package.json b/frontend/package.json similarity index 100% rename from aapc-frontend/package.json rename to frontend/package.json diff --git a/aapc-frontend/postcss.config.js b/frontend/postcss.config.js similarity index 100% rename from aapc-frontend/postcss.config.js rename to frontend/postcss.config.js diff --git a/aapc-frontend/tailwind.config.ts b/frontend/tailwind.config.ts similarity index 100% rename from aapc-frontend/tailwind.config.ts rename to frontend/tailwind.config.ts diff --git a/aapc-frontend/tsconfig.json b/frontend/tsconfig.json similarity index 100% rename from aapc-frontend/tsconfig.json rename to frontend/tsconfig.json diff --git a/aapc-types/.gitignore b/types/.gitignore similarity index 100% rename from aapc-types/.gitignore rename to types/.gitignore diff --git a/aapc-types/dist/main.d.mts b/types/dist/main.d.mts similarity index 100% rename from aapc-types/dist/main.d.mts rename to types/dist/main.d.mts diff --git a/aapc-types/dist/main.d.ts b/types/dist/main.d.ts similarity index 100% rename from aapc-types/dist/main.d.ts rename to types/dist/main.d.ts diff --git a/aapc-types/dist/main.js b/types/dist/main.js similarity index 100% rename from aapc-types/dist/main.js rename to types/dist/main.js diff --git a/aapc-types/dist/main.js.map b/types/dist/main.js.map similarity index 100% rename from aapc-types/dist/main.js.map rename to types/dist/main.js.map diff --git a/aapc-types/dist/main.mjs b/types/dist/main.mjs similarity index 100% rename from aapc-types/dist/main.mjs rename to types/dist/main.mjs diff --git a/aapc-types/dist/main.mjs.map b/types/dist/main.mjs.map similarity index 100% rename from aapc-types/dist/main.mjs.map rename to types/dist/main.mjs.map diff --git a/aapc-types/main.ts b/types/main.ts similarity index 100% rename from aapc-types/main.ts rename to types/main.ts diff --git a/aapc-types/package-lock.json b/types/package-lock.json similarity index 100% rename from aapc-types/package-lock.json rename to types/package-lock.json diff --git a/aapc-types/package.json b/types/package.json similarity index 86% rename from aapc-types/package.json rename to types/package.json index a501abb9..af0446c8 100644 --- a/aapc-types/package.json +++ b/types/package.json @@ -1,7 +1,6 @@ { - "name": "aapc-types", - "version": "0.2.0", - "private": true, + "name": "@aapc/types", + "version": "0.2.1", "description": "Types definitions for the AAPC website.", "main": "./dist/main.js", "module": "./dist/main.mjs", diff --git a/aapc-types/src/Article.ts b/types/src/Article.ts similarity index 100% rename from aapc-types/src/Article.ts rename to types/src/Article.ts diff --git a/aapc-types/src/User.ts b/types/src/User.ts similarity index 100% rename from aapc-types/src/User.ts rename to types/src/User.ts diff --git a/aapc-types/tests/Article.test.ts b/types/tests/Article.test.ts similarity index 100% rename from aapc-types/tests/Article.test.ts rename to types/tests/Article.test.ts diff --git a/aapc-types/tests/User.test.ts b/types/tests/User.test.ts similarity index 100% rename from aapc-types/tests/User.test.ts rename to types/tests/User.test.ts diff --git a/aapc-types/tsconfig.json b/types/tsconfig.json similarity index 100% rename from aapc-types/tsconfig.json rename to types/tsconfig.json diff --git a/aapc-types/tsup.config.ts b/types/tsup.config.ts similarity index 100% rename from aapc-types/tsup.config.ts rename to types/tsup.config.ts diff --git a/aapc-types/vitest.config.ts b/types/vitest.config.ts similarity index 100% rename from aapc-types/vitest.config.ts rename to types/vitest.config.ts