Skip to content

Commit 5582c31

Browse files
authored
feat: first build of website (#12)
* 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
1 parent ca284f0 commit 5582c31

90 files changed

Lines changed: 3410 additions & 708 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: API Tests
1+
name: Pipeline
22

33
on:
44
push:
@@ -7,12 +7,12 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build:
10+
test-backend:
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
1616

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

3030
- name: Tear down test environment
3131
run: docker compose -f docker-compose.test.yml down
32+
33+
build-application:
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v3
39+
40+
- name: Setup prod environment
41+
run: docker compose -f docker-compose.prod.yml up -d --build
42+
43+
- name: Tear down prod environment
44+
run: docker compose -f docker-compose.prod.yml down

CONTRIBUTING.md

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,107 @@
11
# Contributing guidelines
22

3-
Thanks for coming onboard to contribute to this project.
3+
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.
4+
5+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
6+
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
7+
"OPTIONAL" in this document are to be interpreted as described in
8+
RFC 2119.
9+
10+
## Table of Contents
11+
- [Coding Guidelines](#coding-guidelines)
12+
1. [General Guidelines](#general-guidelines)
13+
2. [Backend Guidelines](#backend-guidelines)
14+
3. [Frontend Guidelines](#frontend-guidelines)
15+
- [Product Demo Guidelines](#product-demo-guidelines)
16+
17+
## Coding Guidelines
18+
### General guidelines
19+
20+
- 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.
21+
22+
- 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.
23+
24+
- You MAY use the test suite in Github Actions to ensure that your current build of the project is stable to push to production.
25+
26+
27+
### Backend Guidelines
28+
29+
- Before merging a PR with backend changes, you SHOULD check that tests pass and that you have tested your own changes.
30+
31+
- ``snake_case`` SHALL be used for all response/request body parameters.
32+
33+
```js
34+
// this is fine
35+
POST HTTP/1.1 /test 200
36+
{
37+
a_variable: "jewdfjskd",
38+
a_very_long_name: "dsfkjsda"
39+
}
40+
41+
GET HTTP/1.1 /test?variable_name=lol 200
42+
43+
// this is not ok
44+
POST HTTP/1.1 /test 200
45+
{
46+
camelCase: "no"
47+
}
48+
```
49+
50+
- You SHOULD throw informative errors when an error occurs in response/query.
51+
52+
```js
53+
// this is good
54+
GET HTTP/1.1 /test 400
55+
{
56+
"error": "missing fields 'asdf', 'err'"
57+
}
58+
59+
// this is not good
60+
GET HTTP/1.1 /test 400
61+
{
62+
"error": "an error occurred. try again later"
63+
}
64+
```
65+
66+
### Frontend guidelines
67+
- Pages (``page.tsx``) SHOULD be written with ``export default function``.
68+
```ts
69+
// good
70+
export default function HomePage {...}
71+
72+
// bad
73+
export const HomePage = () => {}
74+
Homepage.displayName = 'HomePage'; // needed for NextJS
75+
export default HomePage;
76+
```
77+
- Non-interactive components SHOULD be made a server component. This SHOULD include all pages (``pages.tsx``).
78+
79+
- Pages SHOULD be broken down into simple, reusable components if possible.
80+
81+
## Product Demo Guidelines
82+
83+
Thanks for coming in to test this project. This section details what to do when testing out demos/test builds.
84+
85+
- 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.
86+
87+
- 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:
88+
89+
- Username: ``a; DROP TABLE users;--`` (SQL injection, for technical users)
90+
- UserID: ``2147483648`` (32 bit signed int overflow)
91+
- Username: ``jjjj...jjjjjj`` (a very long string that may exceed memory limits)
92+
- Email: ``a.dsfsajf`` (an input that is clearly not an email)
93+
- Birthday: ``30/2/2023`` (a date that does not exist)
94+
- Age: ``-1`` (an age that cannot exist)
95+
- Start time: ``09:00``, End time: ``08:00`` (End time < Start time)
96+
- Day of the week: ``Yesterday`` (Not a day of the week)
97+
- Month: ``Decembuary`` (Not a month)
98+
99+
- 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.
100+
101+
- Look out for behaviour that may be too complex for a normal user, or is not supported on touchscreen devices.
102+
103+
4104
5-
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.
6105
7-
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.
8106
9-
Before merging a PR, please check that CI/CD tests pass and that you have tested your own changes.
10107

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ Clone with ``git clone https://github.com/raffles-interact/interapp.git``
1717

1818
### Running
1919

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

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

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

2626
## Setting up (testing/non-technical)
2727

28+
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.
29+
2830
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/).
2931

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

3436
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!).
3537

36-
5. Run ``docker compose -f docker-compose.dev.yml up --build -d``.
38+
5. Run ``docker compose -f docker-compose.prod.yml up --build -d``.
3739

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

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

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

4347
## thanks
4448
thank you for coming here :kekw:

docker-compose.dev.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ services:
2020
timeout: 2s
2121
retries: 5
2222
start_period: 60s
23+
deploy:
24+
resources:
25+
reservations:
26+
cpus: '0.5'
27+
memory: 2G
2328

2429
redis:
2530
container_name: interapp-redis
@@ -100,6 +105,12 @@ services:
100105
depends_on:
101106
- backend
102107
- postgres
108+
deploy:
109+
resources:
110+
reservations:
111+
cpus: '0.5'
112+
memory: 3G
113+
103114

104115
networks:
105116
interapp-network:

interapp-backend/.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ POSTGRES_PORT=5432
77
API_PORT=8000
88

99
REDIS_URL=redis://interapp-redis:6379
10+
FRONTEND_URL=http://localhost:3000
1011

1112
SCHOOL_EMAIL_REGEX="^[A-Za-z0-9]+@student\.ri\.edu\.sg|[A-Za-z0-9]+@rafflesgirlssch.edu.sg$"

interapp-backend/.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ POSTGRES_PORT=5432
77
API_PORT=8000
88

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

1112
SCHOOL_EMAIL_REGEX="^[A-Za-z0-9]+@student\.ri\.edu\.sg|[A-Za-z0-9]+@rafflesgirlssch.edu.sg$"
Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
1-
<h1>RESET PASSWORD</h1>
2-
<p>Hi {{ username }},</p>
3-
<p>Click the link below to reset your password:</p>
4-
<p>{{ token }}</p>
5-
<p><a href="{{ url }}">Reset Now!</a></p>
1+
<head>
2+
<title>Reset password email</title>
3+
<style>
4+
body {
5+
font-family: Arial, Helvetica, sans-serif;
6+
}
7+
8+
.title {
9+
font-size: 20px;
10+
font-weight: bold;
11+
}
12+
.content {
13+
font-size: 16px;
14+
}
15+
.button {
16+
background-color: #da2400;
17+
border: none;
18+
color: white;
19+
padding: 10px 20px;
20+
text-align: center;
21+
text-decoration: none;
22+
display: inline-block;
23+
}
24+
.button a {
25+
color: white;
26+
text-decoration: none;
27+
font-weight: bold;
28+
}
29+
</style>
30+
</head>
31+
<body>
32+
<div>
33+
<h1 class="title">Reset your password on Interapp!</h1>
34+
<p class="content">Hi {{ username }},</p>
35+
<p class="content">Click the link below to reset your password:</p>
36+
<button class="content button"><a href="{{ url }}">Reset</a></button>
37+
<p class="content">
38+
If you did not request this, please ignore this email. Do not click on the reset password and
39+
contact the administrator immediately.
40+
</p>
41+
<p class="content">Thanks,</p>
42+
<p class="content">Interapp Team</p>
43+
<hr />
44+
<p class="content">
45+
If you're having trouble clicking the "Reset" button, copy and paste the URL below into your
46+
web browser: <a href="{{ url }}">{{ url }}</a>
47+
</p>
48+
</div>
49+
</body>
Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
1-
<h1>VERIFY EMAIL</h1>
2-
<p>Hi {{ username }},</p>
3-
<p>Click the link below to verify email:</p>
4-
<p>{{ token }}</p>
5-
<p><a href="{{ url }}">Reset Now!</a></p>
1+
<head>
2+
<title>Verify email</title>
3+
<style>
4+
body {
5+
font-family: Arial, Helvetica, sans-serif;
6+
}
7+
8+
.title {
9+
font-size: 20px;
10+
font-weight: bold;
11+
}
12+
.content {
13+
font-size: 16px;
14+
}
15+
.button {
16+
background-color: #da2400;
17+
border: none;
18+
color: white;
19+
padding: 10px 20px;
20+
text-align: center;
21+
text-decoration: none;
22+
display: inline-block;
23+
}
24+
.button a {
25+
color: white;
26+
text-decoration: none;
27+
font-weight: bold;
28+
}
29+
</style>
30+
</head>
31+
<body>
32+
<div>
33+
<h1 class="title">Verify your email with Interapp!</h1>
34+
<p class="content">Hi {{ username }},</p>
35+
<p class="content">Click the link below to verify your email:</p>
36+
<button class="content button"><a href="{{ url }}">Verify Now!</a></button>
37+
<p class="content">If you did not request this, please ignore this email.</p>
38+
<p class="content">Thanks,</p>
39+
<p class="content">Interapp Team</p>
40+
<hr />
41+
<p class="content">
42+
If you're having trouble clicking the "Verify Now" button, copy and paste the URL below into
43+
your web browser: <a href="{{ url }}">{{ url }}</a>
44+
</p>
45+
</div>
46+
</body>

0 commit comments

Comments
 (0)