npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

42-fast-api

v1.0.1

Published

> [!NOTE] > Development started on **October 20, 2024**, and it is currently in progress.

Downloads

150

Readme

FortyTwo API Client

[!NOTE] Development started on October 20, 2024, and it is currently in progress.

A simplified client for interacting with the 42 API. This project aims to provide an easy-to-use interface to manage OAuth2 tokens and make authenticated API requests.

Features

  • Automatically retrieves and manages OAuth2 tokens.
  • Simplified API requests for GET and POST methods.
  • Customizable logging for API requests.
  • TypeScript support with typed responses.

Installation

To install the package, run:

npm install 42-fast-api

or

yarn add 42-fast-api

or

pnpm add 42-fast-api

pnpm is recommended for faster installation and better dependency management.

Usage

Start by creating a .env file with your UID and SECRET from the 42 API:

UID=your_client_id
SECRET=your_client_secret

Example of how to use the client:

import { FortyTwoAPI } from "./src/api";

if (!process.env.UID || !process.env.SECRET) {
  throw new Error("Please provide UID and SECRET in .env file");
}

const api = new FortyTwoAPI({
  uid: process.env.UID,
  secret: process.env.SECRET,
  logRequests: true,
  baseUrl: "https://api.intra.42.fr",
});

(async () => {
  try {
    await api.init();
    const userId = await api.users.getUserIdByLogin("example_login");
    console.log(userId);

    const userData = await api.users.getUserData(userId);
    console.table(userData.projects_users);
  } catch (error) {
    console.error(error);
  }
})();

API

init()

Initializes the client and retrieves the access token.

getUserIdByLogin(login: string): Promise<string>

Fetches the user ID for a given login.

getUserData(userId: string): Promise<UserData>

Retrieves detailed data for a user by ID.

getCampusList(): Promise<any>

Returns a list of all campuses from the API.

Logging

You can enable request logging by setting logRequests to true in the constructor.

Development

This project is still in development. Feel free to contribute by submitting issues or pull requests.

License

This project is licensed under the MIT License.