Skip to content

42-stud/next-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42 next-api

A lightweight REST API built with Node.js, Express and TypeScript to access 42 School resources (user profile, level, modules, clusters, exams, attendance, activities, position, etc.).

Live

The API is hosted at: https://42.zwuiix.dev/

Tech Stack

  • Node.js
  • Express 5
  • TypeScript
  • Playwright (session handling)
  • Axios

Project Structure

src/
├── app.ts            # Express application setup
├── server.ts         # Server entry point
├── auth/             # Session and cookie management
├── controllers/      # Route controllers
├── routes/           # API routes
├── services/         # Business logic / 42 API calls
├── scripts/          # Auth scripts
└── utils/            # Helpers (cache, etc.)

Getting Started

Prerequisites

  • Node.js 18+
  • npm

Installation

npm install

Environment Variables

Create a .env file at the root with the required credentials (42 intra credentials and any session-related variables used by auth/session.ts).

Run in development

npm run dev

Build and run in production

npm run build
npm start

Endpoints

All endpoints are exposed under /api.

Method Endpoint Description
GET /api/user Get user profile
GET /api/level Get user level
GET /api/modules Get user modules
GET /api/clusters Get user clusters
GET /api/exams Get user exams
GET /api/attendance Get user attendance
GET /api/activities Get user activities
GET /api/position Get user position
GET /health Health check

Notes

  • The service handles its own session and cookies for the 42 intranet.
  • CORS is restricted to http://localhost:4321 and https://portfolio.zwuiix.dev.
  • This project is not affiliated with 42 School.

License

ISC

About

A lightweight REST API built with Node.js, Express and TypeScript to access 42 School resources (user profile, level, modules, clusters, exams, attendance, activities, position, etc.).

Resources

Stars

Watchers

Forks

Contributors