Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy admin web on production #639

Merged
merged 69 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
bfb8827
Enter pre-release mode
github-actions[bot] Aug 11, 2023
f3f35b9
feat: create elasticsearch module
samithiwat Feb 5, 2023
246bab1
feat: create search module
samithiwat Feb 5, 2023
a0fc5fd
Revert "feat: create elasticsearch module"
samithiwat Feb 5, 2023
4d28253
feat(repo): add prettier organize plugin
samithiwat Feb 6, 2023
6c7a631
chore: move isTime function to utils
samithiwat Feb 6, 2023
c1043f2
feat: add course index in env file
samithiwat Feb 6, 2023
5d325e3
feat: update configuration file
samithiwat Feb 6, 2023
2467b99
feat: add search module to app module
samithiwat Feb 6, 2023
2a38114
chore(repo): remove unused files
samithiwat Feb 6, 2023
81f608f
chore(repo): remove unused files
samithiwat Feb 6, 2023
ff98b7b
feat: create course search interface
samithiwat Feb 6, 2023
0adba28
feat: import elasticsearch module in search module
samithiwat Feb 6, 2023
1b358e2
feat: implement search service
samithiwat Feb 6, 2023
5560911
feat: implement with course service
samithiwat Feb 6, 2023
2b1b7b3
feat: add pagination
samithiwat Feb 6, 2023
0f82908
refactor: change search service to use search request as input
samithiwat Feb 6, 2023
f019c7f
chore: add courseIndex to required configuration
samithiwat Feb 7, 2023
bc749c6
chore(dep): move prettier plugin organize import to root package
samithiwat Feb 7, 2023
7a23b1e
refactor: change calling search method from course service to course …
samithiwat Feb 7, 2023
24caf9f
chore(dep): update lock file
samithiwat Feb 7, 2023
5cd8e24
refactor: move interface to resolver
samithiwat Feb 7, 2023
d77d3c6
chore: change return type to Course graphql
samithiwat Feb 7, 2023
628ffca
chore: remove unused import
samithiwat Feb 7, 2023
7282ea1
feat(repo): add changeset
samithiwat Feb 7, 2023
ca67fa3
chore(dep): add opensearch nestjs
samithiwat Aug 26, 2023
901323e
refactor: change to use opensearch nestjs
samithiwat Aug 26, 2023
e69a894
chore: update config
samithiwat Aug 26, 2023
c9efb77
chore: remove unused statement
samithiwat Aug 26, 2023
26e804b
refactor: update to beta v1.6.0
samithiwat Aug 26, 2023
9396969
feat: register opensearch search service
samithiwat Aug 26, 2023
99182bb
chore(dep): add opensearch nestjs
samithiwat Aug 26, 2023
5ab038f
feat: implement search service
samithiwat Aug 26, 2023
8e6e997
fix: ssl problem
samithiwat Aug 26, 2023
7a1b6d8
refactor: update query for opensearch lib
samithiwat Aug 26, 2023
659e332
chore(dep): update lock file
samithiwat Aug 27, 2023
4149d47
feat: update template of scraper
samithiwat Aug 27, 2023
197f0a9
feat: update scraper config
samithiwat Aug 27, 2023
3245f28
feat: create opensearch cli for create index
samithiwat Aug 27, 2023
007a78a
feat: finish search feature
samithiwat Aug 27, 2023
2180855
chore(docs): update index information
samithiwat Aug 27, 2023
17f30ed
chore: implement upsert data from scraper to opensearch
samithiwat Aug 27, 2023
6b650ec
Update .changeset/enhance-search-engine.md
samithiwat Aug 27, 2023
a41e4b4
refactor: move build course query to subdirectory
samithiwat Aug 27, 2023
a335f16
fix: config error
samithiwat Aug 27, 2023
2d2493e
feat: change cli to execute file
samithiwat Aug 27, 2023
a950fca
chore: update as review
samithiwat Aug 27, 2023
ed9fddb
chore: add go project for opensearch cli
samithiwat Aug 28, 2023
5ef909d
chore: optimize search query
samithiwat Aug 30, 2023
b604bc0
fix misconfigured write
saengowp Sep 2, 2023
43f7c0b
support prefix course no and partial course abbr query
saengowp Sep 2, 2023
c978a3a
fix aliasing
saengowp Sep 2, 2023
a692e0a
Merge pull request #509 from thinc-org/feat/search-enhance
samithiwat Sep 2, 2023
79af67e
chore: bump mongoose (fix vulnerabilities) (#627)
leomotors Sep 12, 2023
8d9d304
ci: fix lint (#628)
leomotors Sep 12, 2023
8e775fe
Version Packages (beta) (#626)
github-actions[bot] Sep 12, 2023
019d92a
feat: backoffice (#560)
khajornritdacha Sep 12, 2023
d57aa7e
chore: add changeset
khajornritdacha Sep 12, 2023
f771ad3
chore: add changeset
khajornritdacha Sep 12, 2023
46e520b
feat(web): not reg chula warning (#629)
leomotors Sep 13, 2023
1918671
Version Packages (beta) (#630)
github-actions[bot] Sep 14, 2023
02c4acb
fix: broken build in previous release (#632)
leomotors Sep 14, 2023
bfda7a7
use cas url instead (#631)
saengowp Sep 14, 2023
7fd8fd8
Version Packages (beta) (#633)
github-actions[bot] Sep 14, 2023
7fe7a91
Feat/backoffice (#634)
khajornritdacha Sep 18, 2023
c5bb0b2
Version Packages (beta) (#635)
github-actions[bot] Sep 18, 2023
c0c50c2
Feat/backoffice (#636)
khajornritdacha Sep 19, 2023
f9de7f6
Version Packages (beta) (#637)
github-actions[bot] Sep 19, 2023
00cd278
Configure pre-release mode
khajornritdacha Sep 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/admin-web-env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'admin-web': patch
---

edit .env for admin-web
6 changes: 6 additions & 0 deletions .changeset/change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'admin-api': major
'admin-web': major
---

init admin-api and admin-web
5 changes: 5 additions & 0 deletions .changeset/enhance-search-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'api': minor
---

Enhance search engine with Elasticsearch
5 changes: 5 additions & 0 deletions .changeset/fix-health-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'admin-api': patch
---

Fix health check path in admin-api
7 changes: 7 additions & 0 deletions .changeset/old-insects-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'admin-web': patch
'admin-api': patch
'web': patch
---

fix broken build in previous release
27 changes: 27 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mode": "exit",
"tag": "beta",
"initialVersions": {
"admin-api": "0.1.1",
"admin-web": "0.1.1",
"api": "1.5.0",
"reg-scraper": "1.1.3",
"web": "1.6.0",
"web-e2e": "0.0.1",
"@cgr/codegen": "1.2.0",
"@cgr/course-utils": "1.0.2",
"@cgr/project-config": "1.0.0",
"@cgr/schema": "1.1.1"
},
"changesets": [
"admin-web-env",
"change",
"enhance-search-engine",
"fix-health-check",
"old-insects-sit",
"spotty-gifts-flash",
"thin-houses-rhyme",
"unlucky-cars-hang",
"violet-sloths-reply"
]
}
5 changes: 5 additions & 0 deletions .changeset/spotty-gifts-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'reg-scraper': minor
---

use cas url instead
5 changes: 5 additions & 0 deletions .changeset/thin-houses-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'web': minor
---

feat: explicit warning not reg chula at first page (Close #623)
13 changes: 13 additions & 0 deletions .changeset/unlucky-cars-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@cgr/project-config': patch
'@cgr/course-utils': patch
'reg-scraper': patch
'@cgr/codegen': patch
'@cgr/schema': patch
'admin-api': patch
'admin-web': patch
'api': patch
'web': patch
---

bump eslint and fix ci
8 changes: 8 additions & 0 deletions .changeset/violet-sloths-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'reg-scraper': minor
'@cgr/schema': minor
'admin-api': minor
'api': minor
---

bump mongoose to 6.12 (fix vulnerabilities)
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ Dockerfile
# turbo cache
.turbo
**/.turbo

volumes/
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ data/
.turbo

out

# opensearch-cli
.idea
opensearch.yaml
apps/opensearch-cli/index/local
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
pnpm-lock.yaml

# Generate files
apps/admin-api/src/graphql.ts
apps/api/src/graphql.ts
packages/codegen/src/generated/**/*
11 changes: 9 additions & 2 deletions apps/admin-api/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ ENV=development

GOOGLE_OAUTH_ID=<insert_client_id>
GOOGLE_OAUTH_SECRET=<insert_client_secret>
CLIENT_ID=<inset_client_id>
CLIENT_SECRET=<insert_client_secret>
AUTHORIZATION_URL=<insert_authorization_url>
TOKEN_URL=<insert_token_url>
USERINFO_URL=<insert_userinfo_url>
REDIRECT_URI=<insert_redirect_uri(backend_url with validate token path)>
CORS_ORIGIN=<insert_frontend_url>
JWT_SECRET=<insert_jwt_secret>

ADMIN_TOKEN=<insert_admin_token>

DASHBOARD_URL=https://appsmith.internal.cugetreg.com/applications/6155d8914a99086ac822a925/pages/61b73ebe0599052fee9c8295
# don't forget /slack suffix if using discord webhook url
SLACK_WEBHOOK_URL=https://discord.com/api/webhooks/xxxx/xxxx/slack

11 changes: 11 additions & 0 deletions apps/admin-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ENV files
.env.local

.env.development
.env.production
.env.local.development
.env.local.production

generate-typings.js

dist
1 change: 0 additions & 1 deletion apps/admin-api/.prettierignore

This file was deleted.

28 changes: 28 additions & 0 deletions apps/admin-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# admin-api

## 1.0.0-beta.3

### Patch Changes

- 7fe7a910: Fix health check path in admin-api

## 1.0.0-beta.2

### Patch Changes

- 02c4acbe: fix broken build in previous release

## 1.0.0-beta.1

### Major Changes

- f771ad38: init admin-api and admin-web

## 0.2.0-beta.0

### Minor Changes

- 79af67e9: bump mongoose to 6.12 (fix vulnerabilities)

### Patch Changes

- 8d9d304b: bump eslint and fix ci

## 0.1.1

### Patch Changes
Expand Down
45 changes: 45 additions & 0 deletions apps/admin-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# When copying this Dockerfile for use in other apps, don't forget to change the scope (api, web, etc.) in RUN commands

FROM node:18-alpine AS pnpm
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update

ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="${PATH}:${PNPM_HOME}"
RUN npm install -g pnpm

# --------------------------------------------------------

FROM pnpm AS pruner
WORKDIR /app
RUN pnpm install -g turbo
COPY . .
RUN turbo prune --scope=admin-api --docker

# --------------------------------------------------------

FROM pnpm AS builder
WORKDIR /app

COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install --frozen-lockfile

COPY --from=pruner /app/out/full/ .
COPY turbo.json turbo.json
RUN pnpm turbo build --filter=admin-api...

# --------------------------------------------------------

FROM pnpm AS runner
WORKDIR /app

COPY --from=pruner /app/out/json/ .
COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install --frozen-lockfile --production

COPY --from=builder /app/apps/admin-api/dist/ apps/admin-api/dist/
COPY --from=builder /app/packages/ packages/

CMD node apps/admin-api/dist/main.js
19 changes: 13 additions & 6 deletions apps/admin-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admin-api",
"version": "0.1.1",
"version": "1.0.0-beta.3",
"description": "",
"author": "",
"private": true,
Expand All @@ -14,27 +14,34 @@
"prebuild": "rimraf dist"
},
"dependencies": {
"@apollo/server": "^4.7.1",
"@cgr/schema": "workspace:*",
"@nestjs/apollo": "^11.0.5",
"@nestjs/axios": "^2.0.0",
"@nestjs/cli": "^9.0.0",
"@nestjs/common": "9.4.0",
"@nestjs/config": "2.2.0",
"@nestjs/core": "9.4.0",
"@nestjs/graphql": "7.9.8",
"@nestjs/graphql": "11.0.5",
"@nestjs/jwt": "7.2.0",
"@nestjs/mongoose": "9.2.1",
"@nestjs/platform-express": "9.4.0",
"@nestjs/schedule": "2.1.0",
"@slack/webhook": "6.0.0",
"@thinc-org/chula-courses": "^2.3.0",
"axios": "0.23.0",
"class-transformer": "0.3.1",
"class-validator": "0.14.0",
"graphql": "15.5.0",
"mongoose": "6.5.2",
"cookie-parser": "1.4.6",
"graphql": "16.6.0",
"mongoose": "6.12.0",
"rxjs": "^7.8.0"
},
"devDependencies": {
"@types/cookie-parser": "^1.4.3",
"@types/express": "^4.17.16",
"@types/jest": "28.1.8",
"@types/node": "^18.11.18",
"eslint": "8.34.0",
"eslint": "8.49.0",
"jest": "28.1.3",
"ts-jest": "28.0.8",
"ts-morph": "^18.0.0",
Expand Down
27 changes: 25 additions & 2 deletions apps/admin-api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
import { Controller, Get } from '@nestjs/common'
import { Controller, Get, Req, UnauthorizedException, UseGuards } from '@nestjs/common'
import { Query } from '@nestjs/graphql'

import { Request } from 'express'

import { AuthService } from '@admin-api/auth/auth.service'
import { JwtAuthGuard } from '@admin-api/auth/oidc.guard'
import { SkipAuth } from '@admin-api/common/decorators/SkipAuth'

import { AppService } from './app.service'

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(
private readonly appService: AppService,
private readonly authService: AuthService
) {}

@Get()
@SkipAuth()
getHello(): string {
return this.appService.getHello()
}

@Query('me')
@UseGuards(JwtAuthGuard)
async getMe(@Req() req: Request) {
if (!req.cookies['accessToken']) {
throw new UnauthorizedException('No access token')
}

return {
success: true,
}
}
}
Loading