Skip to content

Commit

Permalink
Merge branch 'main' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Dec 11, 2023
2 parents 7487142 + 0959083 commit 81de5ba
Show file tree
Hide file tree
Showing 22 changed files with 1,165 additions and 5,269 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will install backend's requirements and run tests

name: Run Backend Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
pytest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd ./backend
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r requirements-test.txt
- name: Test with pytest
run: |
cd ./backend/test && python -m pytest
28 changes: 25 additions & 3 deletions backend/src/appointment/controller/apis/google_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,55 @@ def get_email(self, token):

def list_calendars(self, token):
response = {}
items = []
with build("calendar", "v3", credentials=token) as service:
request = service.calendarList().list()
while request is not None:
try:
response = request.execute()

items += response.get('items', [])
except HttpError as e:
logging.warning(f"[google_client.list_calendars] Request Error: {e.status_code}/{e.error_details}")

request = service.calendarList().list_next(request, response)

return response.get("items", [])
return items

def list_events(self, calendar_id, time_min, time_max, token):
response = {}
items = []

# Limit the fields we request
fields = ','.join(
(
'items/status',
'items/summary',
'items/description',
'items/attendees',
'items/start',
'items/end',
# Top level stuff
'nextPageToken',
)
)

with build("calendar", "v3", credentials=token) as service:
request = service.events().list(
calendarId=calendar_id, timeMin=time_min, timeMax=time_max, singleEvents=True, orderBy="startTime"
calendarId=calendar_id, timeMin=time_min, timeMax=time_max, singleEvents=True, orderBy="startTime",
fields=fields
)
while request is not None:
try:
response = request.execute()

items += response.get('items', [])
except HttpError as e:
logging.warning(f"[google_client.list_events] Request Error: {e.status_code}/{e.error_details}")

request = service.events().list_next(request, response)

return response.get("items", [])
return items

def create_event(self, calendar_id, body, token):
response = None
Expand Down
5 changes: 4 additions & 1 deletion backend/src/appointment/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ def server():
from .routes import zoom
from .routes import webhooks

# Hide openapi url (which will also hide docs/redoc) if we're not dev
openapi_url = '/openapi.json' if os.getenv('APP_ENV') == 'dev' else None

# init app
app = FastAPI()
app = FastAPI(openapi_url=openapi_url)

app.add_middleware(
SessionMiddleware,
Expand Down
16 changes: 8 additions & 8 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Appointment frontend configuration.

# -- Frontend --
VUE_APP_BASE_URL=localhost:8080
VUE_APP_SHORT_BASE_URL=localhost:8080/user
VITE_BASE_URL=localhost:8080
VITE_SHORT_BASE_URL=localhost:8080/user

# -- Backend API --
VUE_APP_API_URL=localhost
VUE_APP_API_PORT=8090
VUE_APP_API_SECURE=false
VITE_API_URL=localhost
VITE_API_PORT=8090
VITE_API_SECURE=false

# -- Sentry --
VUE_APP_SENTRY_DSN=
VITE_SENTRY_DSN=

# -- Auth scheme --
VUE_APP_AUTH_SCHEME=password
VITE_AUTH_SCHEME=password

# For fxa
VUE_APP_FXA_EDIT_PROFILE=
VITE_FXA_EDIT_PROFILE=
12 changes: 6 additions & 6 deletions frontend/.env.staging.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Production env config, do not put secrets in here !!
VUE_APP_API_URL=stage.appointment.day/api/v1/
VUE_APP_BASE_URL=stage.appointment.day
VUE_APP_API_SECURE=true
VUE_APP_SHORT_BASE_URL=https://stage.apmt.day
VITE_API_URL=stage.appointment.day/api/v1/
VITE_BASE_URL=stage.appointment.day
VITE_API_SECURE=true
VITE_SHORT_BASE_URL=https://stage.apmt.day

# -- Auth scheme --
VUE_APP_AUTH_SCHEME=fxa
VITE_AUTH_SCHEME=fxa

# For fxa
VUE_APP_FXA_EDIT_PROFILE=https://accounts.stage.mozaws.net/settings
VITE_FXA_EDIT_PROFILE=https://accounts.stage.mozaws.net/settings
74 changes: 40 additions & 34 deletions frontend/.eslintrc.js → frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'plugin:vue/vue3-essential',
'airbnb-base',
],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'vue',
],
rules: {
'import/extensions': ['error', 'ignorePackages', {
'': 'never',
js: 'never',
vue: 'off', // TODO: once migrated to Vite, we should set this to 'always'
}],
'max-len': ['error', { code: 120 }],
'no-param-reassign': 'off',
},
settings: {
'import/resolver': {
webpack: {
config: require.resolve('@vue/cli-service/webpack.config.js'),
},
},
},
};
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'plugin:vue/vue3-essential',
'airbnb-base',
],
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'vue',
],
rules: {
'import/extensions': ['error', 'ignorePackages', {
'': 'never',
js: 'never',
vue: 'off',
}],
'max-len': ['error', {code: 120}],
'no-param-reassign': 'off',
},
settings: {
'import/resolver': {
alias: {
map: [
['@', './src'],
],
extensions: ['.js', '.vue'],
},
},
},
};
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ pnpm-debug.log*
*.njsproj
*.sln
*.sw?

# Sentry Config File
.env.sentry-build-plugin
26 changes: 13 additions & 13 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM node:lts-alpine

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

# Get git
RUN apk add --no-cache git

COPY . .
RUN yarn install

CMD vue-cli-service serve
FROM node:lts-alpine

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

# Get git
RUN apk add --no-cache git

COPY . .
RUN yarn install

CMD vite dev --port 8080
6 changes: 3 additions & 3 deletions frontend/deploy.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
apt-get install -y nodejs

# Build site
RUN cd /build/frontend && npm install
RUN cd /build/frontend && npm run build-stage
RUN cd /build/frontend && yarn install
RUN cd /build/frontend && yarn build -- --mode stage

# Use our custom nginx config
RUN rm /etc/nginx/conf.d/default.conf
COPY docker/etc/nginx/conf.d/appointments.conf /etc/nginx/conf.d/default.conf

RUN cp -r /build/frontend/dist/. /usr/share/nginx/html

EXPOSE 80
EXPOSE 80
11 changes: 5 additions & 6 deletions frontend/public/index.html → frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<!DOCTYPE html>
<html lang="">
<head>
<title><%= htmlWebpackPlugin.options.title %></title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>appointment_logo.svg">
<meta charset="UTF-8">
<link rel="icon" href="/appointment_logo.svg">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thunderbird Appointment</title>
<script>
// handle theme color scheme
if (
Expand All @@ -26,6 +25,6 @@
</strong>
</noscript>
<div id="app" class="h-full"></div>
<!-- built files will be auto injected -->
<script type="module" src="/src/main.js"></script>
</body>
</html>
19 changes: 4 additions & 15 deletions frontend/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
{
"compilerOptions": {
"target": "ES6",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"jsx": "preserve",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
}
41 changes: 16 additions & 25 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,41 @@
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"build-stage": "vue-cli-service build --mode staging",
"lint": "yarn run eslint --ext .js,.vue ./src"
"dev": "vite --port 8080",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --ignore-path .gitignore",
"lint:fix": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
},
"dependencies": {
"@auth0/auth0-vue": "^2.0.2",
"@sentry/vite-plugin": "^2.10.2",
"@sentry/vue": "^7.56.0",
"@sentry/webpack-plugin": "^2.3.0",
"@tabler/icons-vue": "^2.4.0",
"@tailwindcss/forms": "^0.5.3",
"@vitejs/plugin-vue": "^4.5.2",
"@vueuse/components": "^10.4.1",
"@vueuse/core": "^10.4.1",
"core-js": "^3.8.3",
"dayjs": "^1.11.5",
"pinia": "^2.1.6",
"tailwindcss": "^3.1.8",
"vite": "^5.0.5",
"vue": "^3.2.13",
"vue-i18n": "^9.2.2",
"vue-router": "^4.0.3"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@tailwindcss/forms": "^0.5.3",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"@rushstack/eslint-patch": "^1.3.3",
"autoprefixer": "^10.4.12",
"eslint": "^8.43.0",
"eslint": "^8.55.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-vue": "^9.12.0",
"eslint-plugin-vue": "^9.19.2",
"postcss": "^8.4.17",
"tailwindcss": "^3.1.8"
},
"babel": {
"presets": [
"@vue/cli-plugin-babel/preset"
]
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
"vite-plugin-eslint": "^1.8.1"
}
}
Loading

0 comments on commit 81de5ba

Please sign in to comment.