Skip to content

call-0f-code/COC-API

Repository files navigation

COC-API

This repository contains the common Express.js API for the backends of our Coding Club's websites , backed by PostgreSQL (via Prisma) and Supabase storage. We’re using Bun as our runtime.

📂 Folder Structure

/
├── prisma/                  # Prisma schema and migration files
│   ├── schema.prisma
│   ├── .env                 # your DATABASE_URL, etc.
│   └── migrations/          # auto‑generated by `bun prisma migrate`
│
├── src/
│   ├── config/              # environment/configuration loaders
│   │   └── index.ts         # loads process.env and exports typed config
│   │
│   ├── db/                  # database client initialization
│   │   └── client.ts        # `export const prisma = new PrismaClient()`
│   │
│   ├── routes/              # Express route definitions
│   │   ├── index.ts         # main router that mounts sub‑routers
│   │   ├── members.ts
│   │   ├── projects.ts
│   │   ├── achievements.ts
│   │   ├── topics.ts
│   │   ├── questions.ts
│   │   ├── interviews.ts
│   │   └── progress.ts
│   │
│   ├── controllers/         # controllers: take req → call services → send res
│   │   ├── member.controller.ts
│   │   ├── project.controller.ts
│   │   ├── achievement.controller.ts
│   │   ├── topic.controller.ts
│   │   ├── question.controller.ts
│   │   ├── interview.controller.ts
│   │   └── progress.controller.ts
│   │
│   ├── services/            # business logic / Prisma queries
│   │   ├── member.service.ts
│   │   ├── project.service.ts
│   │   ├── achievement.service.ts
│   │   ├── topic.service.ts
│   │   ├── question.service.ts
│   │   ├── interview.service.ts
│   │   └── progress.service.ts
│   │
│   ├── utils/               # shared helpers (e.g. error wrappers, validators)
│   │   └── apiError.ts
│   │
│   ├── app.ts               # configure Express app, mount routes, error handler
│   └── server.ts            # start HTTP server (calls `app.listen`)
│
├── tests/                   # integration and unit tests (Jest or Mocha)
│   ├── members.test.ts
│   └── ...
│
├── .env.example             # template for environment variables
├── package.json
└── tsconfig.json            # TypeScript configuration

🚀 Getting Started

Prerequisite

  • Install Bun on your machine.

1. Clone the repo

git clone https://github.com/your-org/coding-club-api.git
cd coding-club-api

2. Install dependencies

bun install

3. Configure environment

  • Copy .env.example to .env
  • Update .env with your Supabase/PostgreSQL connection URL and any other variables:

4. Initialize Prisma & Database

bun prisma migrate dev --name init
bun prisma generate

5. Run in development

bun run dev
  • By default, the server listens on http://localhost:3000
  • app.ts sets up your Express instance; server.ts starts the HTTP listener

6. Run tests

bun test

📦 Scripts

Command Description
bun run dev Start the dev server with hot reloading
bun prisma migrate dev --name Apply migrations in development
bun prisma generate Generate Prisma client
bun test Run tests (Jest or Mocha)

🤝 Contributing

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/XYZ)
  3. Commit your changes (git commit -m "feat: add XYZ")
  4. Push to the branch (git push origin feature/XYZ)
  5. Open a Pull Request

📜 License

GNU General Public License v3.0

Happy coding!

About

An API for call of code centralized database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors