Skip to content

Commit

Permalink
feat: Add backend (#37)
Browse files Browse the repository at this point in the history
* Add database configuration and schema

* chore: fix pnpm lock

* refactor: extract student info constants

* feat: database

* feat: member api

* chore: update readme and env example comments

* chore(constant): newlines between constants

* fix(db/schema): `expired_at` -> `expires_at`

---------

Co-authored-by: Rishi Adhikari <[email protected]>
  • Loading branch information
jsun969 and rishiad authored Jan 24, 2024
1 parent 125dec0 commit c2dba5c
Show file tree
Hide file tree
Showing 16 changed files with 1,255 additions and 85 deletions.
9 changes: 7 additions & 2 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=YOUR_NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
CLERK_SECRET_KEY=YOUR_CLERK_SECRET_KEY
# Clerk. See https://clerk.com
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=

# Database. Do not modify in development.
DATABASE_URL=file:dev.sqlite
DATABASE_AUTH_TOKEN=
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# SQLite dev database
*.db
*.sqlite
41 changes: 12 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,23 @@
# CS Club Website

---
## Development

This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:
1. Install dependencies

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
pnpm i
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:
2. Rename `.env.local.example` to `.env.local` and edit it

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
3. Initialize database

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel
```bash
pnpm run db:push
```

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
4. Run dev server

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
```bash
pnpm run dev
```
11 changes: 11 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { loadEnvConfig } from '@next/env';
loadEnvConfig(process.cwd());

import type { Config } from 'drizzle-kit';

export default {
schema: './src/db/schema.ts',
out: './src/db/migration',
driver: 'turso',
dbCredentials: { url: process.env.DATABASE_URL!, authToken: process.env.DATABASE_AUTH_TOKEN },
} satisfies Config;
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@
"start": "next start",
"lint": "cross-env SKIP_ENV_VALIDATION=true next lint",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css,json,mjs,cjs,yml,yaml}\"",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,css,json,mjs,cjs,yml,yaml}\""
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,css,json,mjs,cjs,yml,yaml}\"",
"db:generate": "drizzle-kit generate:sqlite",
"db:push": "drizzle-kit push:sqlite",
"db:studio": "drizzle-kit studio"
},
"dependencies": {
"@clerk/clerk-react": "^4.30.3",
"@clerk/nextjs": "^4.29.3",
"@hookform/resolvers": "^3.3.4",
"just-submit": "^0.0.7",
"@libsql/client": "0.4.0-pre.7",
"@t3-oss/env-nextjs": "^0.7.3",
"drizzle-orm": "^0.29.3",
"drizzle-zod": "^0.5.1",
"just-submit": "^0.0.7",
"ky": "^1.2.0",
"nanoid": "^5.0.4",
"next": "14.0.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -26,6 +34,7 @@
"zustand": "^4.4.7"
},
"devDependencies": {
"@next/env": "^14.1.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.11.0",
"@types/react": "^18.2.47",
Expand All @@ -34,6 +43,7 @@
"@typescript-eslint/parser": "^6.19.0",
"autoprefixer": "^10.4.16",
"cross-env": "^7.0.3",
"drizzle-kit": "^0.20.13",
"eslint": "^8.56.0",
"eslint-config-next": "14.0.3",
"eslint-config-prettier": "^9.1.0",
Expand Down
Loading

0 comments on commit c2dba5c

Please sign in to comment.