Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ DATABASE_URL=
# Direct connection to the database. Used for migrations
DIRECT_URL=

# Retrieve these values based on your Telegram dev bot
BOT_TOKEN=
SECRET_KEY=

NEXT_PUBLIC_TELEGRAM_LOGIN_BOT=

# Can be left blank - set only in production
SECRET_KEY=
NEXT_PUBLIC_POSTHOG_KEY=
NEXT_PUBLIC_POSTHOG_HOST=
55 changes: 38 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,60 @@ The frontend for the NUSCC Website.
## 💻 Technologies Used

- **Frontend**: Next.js, React, TypeScript
- **Database**: Prisma, Supabase
- **Styling**: Tailwind CSS, Shadcn UI components
- **State Management**: React Hooks (useState, useEffect)
- **Icons**: Lucide React
- **Date Handling**: date-fns

## 🚀 Getting Started

### Prerequisites

- Node.js (v20+)
- pnpm
- Node.js (v22+)
- [pnpm](https://pnpm.io/installation)
- Any tool to expose localhost to https endpoints, such as [ngrok](https://ngrok.com/docs/getting-started) or [tunnl.gg](https://tunnl.gg/)
- This guide will be assuming you are using ngrok

### Installation

1. Set up your Telegram dev bot
1. Go to [@BotFather](https://t.me/BotFather) on Telegram
1. Run `/newbot`
1. Enter a username for the bot (e.g. nusc_web_dev_bot) -> BotFather will send with a BOT_TOKEN e.g. XXXXXXXX
1. In your `.env` file, set the following variables:
- Set `BOT_TOKEN` with the token given by [@BotFather](https://t.me/BotFather)
- Set `NEXT_PUBLIC_TELEGRAM_LOGIN_BOT` with your bot username

1. Clone the repository:

```bash
git clone https://github.com/usdevs/NUSCweb
cd NUSCweb
```
```bash
git clone https://github.com/usdevs/NUSCweb
cd NUSCweb
```

1. Install dependencies:

```bash
pnpm install
```
```bash
pnpm install
```

1. Setup your environment variables in `.env` file, with `.env.example` for reference

1. Expose your localhost port:

1. Setup your environment variables in `.env` file
```bash
ngrok http 3000
```

- Retrieve your custom HTTPS URL (e.g. https://xxx.ngrok.io)
- In [@BotFather](https://t.me/BotFather), run `/setdomain`, choose your nusc dev bot, and enter the ngrok URL

1. Run the development server:

```bash
pnpm dev
```
```bash
pnpm dev
```

1. Access our dev server via the ngrok HTTPS URL (e.g. https://xxx.ngrok.io)

## ❓ Common Errors

1. Open <http://localhost:3000> in your browser to see the frontend.
1. If you see "Bot domain invalid" on the top nav bar, ensure your accessing your dev environment via the ngrok HTTPS URL, not your localhost
2 changes: 1 addition & 1 deletion src/lib/utils/server/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { default as jwt } from 'jsonwebtoken';

const SECRET_KEY = process.env.SECRET_KEY || 'hello';
const SECRET_KEY = process.env.SECRET_KEY || 'secret';

export const generateToken = (payload: string | Buffer | object): string =>
jwt.sign(payload, SECRET_KEY, {
Expand Down