Skip to content

Commit

Permalink
Init NPM Support
Browse files Browse the repository at this point in the history
  • Loading branch information
wyatt-herkamp committed Aug 21, 2024
1 parent becade2 commit 644fe75
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions nitro_repo/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub use staging::*;
mod repo_http;
pub use repo_http::*;
pub mod maven;
pub mod npm;
mod repo_type;
pub use repo_type::*;
use thiserror::Error;
Expand Down
48 changes: 48 additions & 0 deletions nitro_repo/src/repository/npm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//! NPM Registry Implementation
//!
//! Documentation for NPM: https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md
use ahash::HashMap;
use chrono::{DateTime, FixedOffset};
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone)]
pub struct RegistryResponse {
pub db_name: String,
pub engine: String,
pub doc_count: u64,
pub doc_del_count: u64,
pub update_seq: u64,
pub purge_seq: u64,
pub compact_running: bool,
// TODO: Add more fields
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NpmRegistryPackage {
#[serde(rename = "_id")]
pub id: String,
#[serde(rename = "_rev")]
pub rev: String,
pub name: String,
pub description: Option<String>,
#[serde(rename = "dist-tags")]
pub dist_tags: HashMap<String, String>,
pub versions: HashMap<String, Value>,
pub time: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NPMRegistryPackageTime {
pub created: String,
pub modified: DateTime<FixedOffset>,
#[serde(flatten)]
pub versions: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Maintainers {
pub name: String,
pub email: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Bugs {
pub url: String,
}

0 comments on commit 644fe75

Please sign in to comment.