Skip to content

Commit

Permalink
feat: first build of website (#12)
Browse files Browse the repository at this point in the history
* chore: restructure tests

* fix: fix hanging connections in recreate db

* fix: tweak ci

* fix: clean up smells

* feat: update docs

* feat: add change email endpoint

* chore: rename actions file

* feat: add get endpoints for permissions and users

* feat: update docs

* fix: duplicate error message on log in

* feat: add navbar

* chore: bump bun version

* fix: tweak signup and signin forms

* fix: make navbar actually sticky

* feat: add footer

* feat: add verification email

* feat: add under construction signage

* chore: hopefully fix promise types

* fix: attempt to fix again with rewrite

* fix: fix again

* fix: smells and navbar title

* feat: prettier verify email template

* fix: tweak verify email page render

* feat: reset pw pages

* feat: prettier emails

* fix: add titleing to emails

* chore: update metadata

* refactor: clean up verify email code

* fix: invalid header

* chore: bump bun version

* fix: reset password email invalid link

* fix: consistency while requesting api routes

* feat: start on settings and admin pages

* chore: prettier

* feat: add admin ability to change email

* feat: add admin functionality to update service hours

* fix: admin change email using wrong jwt

* feat: allow deletion of user account

* feat: admin page

* chore: add loading states for login and signup

* feat: pagination and authprovider tweaks

* fix: update navbar

* feat: settings page

* fix: misc fixes
  • Loading branch information
SebassNoob authored Dec 16, 2023
1 parent ca284f0 commit 5582c31
Show file tree
Hide file tree
Showing 90 changed files with 3,410 additions and 708 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/api_tests.yml → .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: API Tests
name: Pipeline

on:
push:
Expand All @@ -7,12 +7,12 @@ on:
workflow_dispatch:

jobs:
build:
test-backend:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup test environment
run: docker compose -f docker-compose.test.yml up -d --build
Expand All @@ -25,7 +25,20 @@ jobs:
- name: Install dependencies
run: cd interapp-backend && bun install
- name: Test with bun
run: cd interapp-backend && bun test --env-file tests/config/.env.test --coverage --timeout 10000
run: cd interapp-backend && bun run test

- name: Tear down test environment
run: docker compose -f docker-compose.test.yml down

build-application:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup prod environment
run: docker compose -f docker-compose.prod.yml up -d --build

- name: Tear down prod environment
run: docker compose -f docker-compose.prod.yml down
105 changes: 101 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,107 @@
# Contributing guidelines

Thanks for coming onboard to contribute to this project.
Thanks for coming onboard to contribute to this project. This document outlines a few common code guidelines when contributing to the project. Lead maintainers can choose to modify these guidelines if they feel it is too strict/lax. Last updated: 12 Dec 2023.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
RFC 2119.

## Table of Contents
- [Coding Guidelines](#coding-guidelines)
1. [General Guidelines](#general-guidelines)
2. [Backend Guidelines](#backend-guidelines)
3. [Frontend Guidelines](#frontend-guidelines)
- [Product Demo Guidelines](#product-demo-guidelines)

## Coding Guidelines
### General guidelines

- All features SHOULD NOT be commited directly to the ``main`` branch, unless you have a very specific reason to do so (eg. CI/CD testing). Otherwise, checkout a new branch and open a PR.

- You SHOULD follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) when making commits to the ``main``/``dev`` branches, and it is RECOMMENDED to do the same on all other branches.

- You MAY use the test suite in Github Actions to ensure that your current build of the project is stable to push to production.


### Backend Guidelines

- Before merging a PR with backend changes, you SHOULD check that tests pass and that you have tested your own changes.

- ``snake_case`` SHALL be used for all response/request body parameters.

```js
// this is fine
POST HTTP/1.1 /test 200
{
a_variable: "jewdfjskd",
a_very_long_name: "dsfkjsda"
}

GET HTTP/1.1 /test?variable_name=lol 200

// this is not ok
POST HTTP/1.1 /test 200
{
camelCase: "no"
}
```
- You SHOULD throw informative errors when an error occurs in response/query.
```js
// this is good
GET HTTP/1.1 /test 400
{
"error": "missing fields 'asdf', 'err'"
}

// this is not good
GET HTTP/1.1 /test 400
{
"error": "an error occurred. try again later"
}
```
### Frontend guidelines
- Pages (``page.tsx``) SHOULD be written with ``export default function``.
```ts
// good
export default function HomePage {...}

// bad
export const HomePage = () => {}
Homepage.displayName = 'HomePage'; // needed for NextJS
export default HomePage;
```
- Non-interactive components SHOULD be made a server component. This SHOULD include all pages (``pages.tsx``).
- Pages SHOULD be broken down into simple, reusable components if possible.
## Product Demo Guidelines
Thanks for coming in to test this project. This section details what to do when testing out demos/test builds.
- Look out for potential complex functionality that is not properly explained. Such behaviour may make it difficult for future users to understand how to use the website.
- Test forms/input fields with a variety of values, and attempt to cause errors if possible. This is really helpful in case an exploit is present in the inputs. Examples of invalid input values that one can test out:
- Username: ``a; DROP TABLE users;--`` (SQL injection, for technical users)
- UserID: ``2147483648`` (32 bit signed int overflow)
- Username: ``jjjj...jjjjjj`` (a very long string that may exceed memory limits)
- Email: ``a.dsfsajf`` (an input that is clearly not an email)
- Birthday: ``30/2/2023`` (a date that does not exist)
- Age: ``-1`` (an age that cannot exist)
- Start time: ``09:00``, End time: ``08:00`` (End time < Start time)
- Day of the week: ``Yesterday`` (Not a day of the week)
- Month: ``Decembuary`` (Not a month)
- Check for discrepancies in responsive display sizes. Ie. Does the size of screen affect readability of certain text/functionality? To test this on a PC, use the in-browser viewport resizing tool (CTRL + Shift + I on Chrome). Refer to your browser's support page for more information.
- Look out for behaviour that may be too complex for a normal user, or is not supported on touchscreen devices.
All features should not be commited directly to the ``main`` or ``dev`` branches, unless you have a very specific reason to do so (eg. CI/CD testing). Otherwise, checkout a new branch and open a PR.
Please follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) when making commits to the ``main``/``dev`` branches, and it is highly recommended to do the same on all other branches.
Before merging a PR, please check that CI/CD tests pass and that you have tested your own changes.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ Clone with ``git clone https://github.com/raffles-interact/interapp.git``

### Running

Ensure you are in the root of the project. Run ``make build`` and ``make run`` (TODO).
Ensure you are in the root of the project, and that ``.env.local`` exists. Run ``make build`` and ``make watch`` (for HMR).

If your IDE is giving you import errors, run ``bun i`` in the terminal.

Go to ``localhost:3000`` for frontend and ``localhost:3000/api`` for api routes

## Setting up (testing/non-technical)

Please get ``.env.local`` from the current maintainers of the project, which is sensitive information that should not be shared. They will guide you on where to put the data.

1. If you're just testing the UI/frontend, just have ``docker`` installed in your terminal and have Docker desktop running. You can install docker [here](https://docs.docker.com/engine/install/).

2. Download the ZIP file (Scroll to the green button 'Code' > 'Local' tab > Download ZIP) and unzip it in your directory of choice.
Expand All @@ -33,12 +35,14 @@ Go to ``localhost:3000`` for frontend and ``localhost:3000/api`` for api routes

4. Verify docker is installed with ``docker -v`` (If the terminal says ``docker`` is not recognised, try reopening another terminal, failing which, restart your computer) and ensure that you have docker desktop open (important!).

5. Run ``docker compose -f docker-compose.dev.yml up --build -d``.
5. Run ``docker compose -f docker-compose.prod.yml up --build -d``.

6. Verify the containers are running by going to docker desktop and ensuring all container icons are **green**.

7. Go to ``localhost:3000`` on your browser, and verify that you can see the site.

8. For contributing, see [CONTRIBUTING.md](CONTRIBUTING.md#product-demo-guidelines)


## thanks
thank you for coming here :kekw:
11 changes: 11 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ services:
timeout: 2s
retries: 5
start_period: 60s
deploy:
resources:
reservations:
cpus: '0.5'
memory: 2G

redis:
container_name: interapp-redis
Expand Down Expand Up @@ -100,6 +105,12 @@ services:
depends_on:
- backend
- postgres
deploy:
resources:
reservations:
cpus: '0.5'
memory: 3G


networks:
interapp-network:
Expand Down
1 change: 1 addition & 0 deletions interapp-backend/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ POSTGRES_PORT=5432
API_PORT=8000

REDIS_URL=redis://interapp-redis:6379
FRONTEND_URL=http://localhost:3000

SCHOOL_EMAIL_REGEX="^[A-Za-z0-9]+@student\.ri\.edu\.sg|[A-Za-z0-9][email protected]$"
1 change: 1 addition & 0 deletions interapp-backend/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ POSTGRES_PORT=5432
API_PORT=8000

REDIS_URL=redis://interapp-redis:6379
FRONTEND_URL=http://localhost:3000 # TODO: Change this to the actual frontend URL

SCHOOL_EMAIL_REGEX="^[A-Za-z0-9]+@student\.ri\.edu\.sg|[A-Za-z0-9][email protected]$"
54 changes: 49 additions & 5 deletions interapp-backend/api/email_handler/templates/reset_password.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
<h1>RESET PASSWORD</h1>
<p>Hi {{ username }},</p>
<p>Click the link below to reset your password:</p>
<p>{{ token }}</p>
<p><a href="{{ url }}">Reset Now!</a></p>
<head>
<title>Reset password email</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}

.title {
font-size: 20px;
font-weight: bold;
}
.content {
font-size: 16px;
}
.button {
background-color: #da2400;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
}
.button a {
color: white;
text-decoration: none;
font-weight: bold;
}
</style>
</head>
<body>
<div>
<h1 class="title">Reset your password on Interapp!</h1>
<p class="content">Hi {{ username }},</p>
<p class="content">Click the link below to reset your password:</p>
<button class="content button"><a href="{{ url }}">Reset</a></button>
<p class="content">
If you did not request this, please ignore this email. Do not click on the reset password and
contact the administrator immediately.
</p>
<p class="content">Thanks,</p>
<p class="content">Interapp Team</p>
<hr />
<p class="content">
If you're having trouble clicking the "Reset" button, copy and paste the URL below into your
web browser: <a href="{{ url }}">{{ url }}</a>
</p>
</div>
</body>
51 changes: 46 additions & 5 deletions interapp-backend/api/email_handler/templates/verify_email.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
<h1>VERIFY EMAIL</h1>
<p>Hi {{ username }},</p>
<p>Click the link below to verify email:</p>
<p>{{ token }}</p>
<p><a href="{{ url }}">Reset Now!</a></p>
<head>
<title>Verify email</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}

.title {
font-size: 20px;
font-weight: bold;
}
.content {
font-size: 16px;
}
.button {
background-color: #da2400;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
}
.button a {
color: white;
text-decoration: none;
font-weight: bold;
}
</style>
</head>
<body>
<div>
<h1 class="title">Verify your email with Interapp!</h1>
<p class="content">Hi {{ username }},</p>
<p class="content">Click the link below to verify your email:</p>
<button class="content button"><a href="{{ url }}">Verify Now!</a></button>
<p class="content">If you did not request this, please ignore this email.</p>
<p class="content">Thanks,</p>
<p class="content">Interapp Team</p>
<hr />
<p class="content">
If you're having trouble clicking the "Verify Now" button, copy and paste the URL below into
your web browser: <a href="{{ url }}">{{ url }}</a>
</p>
</div>
</body>
Loading

0 comments on commit 5582c31

Please sign in to comment.