Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
gitlab-restapi
Advanced tools
The module allows you to perform the list of methods described in the GitLab service documentation in the section Jobs , Pipelines ( for now)
And you can Add your own method that is not yet implemented by this api
And yes, let's start!
First install Node.js
npm i gitlab-restapi
const GitLab = require("gitlab-restapi");
const gitLab = new GitLab.API(new GitLab.Options({
privateToken: process.env.GIT_TOKEN,
projectId: process.env.GIT_PID,
}));
const jobs = await gitLab.Jobs.jobs(
new GitLab.PaginateParams({
page: 1, per_page: 100, scope: ['success', 'failed']
}));
// find first(last executed) Job by name
const job = jobs.find({name: 'testofclasses'});
console.log(job.status)
GitLab.Options can specify your method for fetching data. For nodes 18+ - this is the own node fetch, for younger versions (unless otherwise specified) - the internal mechanism
new GitLab.Options({
privateToken: process.env.GIT_TOKEN,
projectId: process.env.GIT_PID,
fetchMethod: fetch // axios, fetch, node-fetch, GitLab.Request (tested)
})
const GitLab = require("gitlab-restapi");
const gitLab = new GitLab.API(new GitLab.Options({
privateToken: process.env.GIT_TOKEN,
projectId: process.env.GIT_PID,
fetchMethod: fetch // axios, fetch, node-fetch, GitLab.Request (tested)
}));
console.log(gitLab.Jobs.methods)
// list of registered APIs
console.log(gitLab.getOwnPropertyNames())
Get a single job of a project
const jobs = await gitLab.Jobs.jobs(
new GitLab.PaginateParams({page: 1, per_page: 1, scope: ['success']}));
// const jobs = await gitLab.Jobs.jobs(new GitLab.PaginateParams({})); // page: 1, per_page: 20, all scopes
// const jobs = await gitLab.Jobs.jobs(); // page: 1, per_page: 20, all scopes
console.log('jobs:', jobs.list)
const _job = jobs.find({status: 'success'});
console.log('found:', _job)
const job = await gitLab.Jobs.job(_job.id);
console.log('Get a single job of a project by id:', job)
Erase a single job of a project (remove job artifacts and a job log)
const jobs = await gitLab.Jobs.jobs(new GitLab.PaginateParams({
page: 1,
per_page: 100,
scope: ['failed', 'canceled']
}));
const erasedJobs = new GitLab.Jobs([])
for (let job of jobs.list) {
if (job.artifacts && job.artifacts.length) {
const obj = await gitLab.Jobs.erase(job.id);
if (obj) erasedJobs.push(obj)
}
}
console.log(erasedJobs.list)
const pipelinelatest = await gitLab.Pipelines.latest();
console.log(pipelinelatest)
const pipelines = await gitLab.Pipelines.pipelines(new GitLab.PaginateParams({
page: 1, per_page: 20, status: 'success', source: 'push',}));
console.log(pipelines.list)
Add your own method that is not yet implemented by this api
gitLab.add('MyGroups').addMethods({
groups: new GitLab.Method({method: 'get', class: GitLab.Responses,
url: () => `groups`})
})
console.log(gitLab.MyGroups.methods)
const groups = await gitLab.MyGroups.groups(
new GitLab.PaginateParams({page: 2, per_page: 20}));
console.log(groups.list)
gitLab.add('MyReleases').addMethods({
releases: new GitLab.Method({method: 'get', class: GitLab.Responses,
url: () => `projects/${gitLab.projectId}/releases`})
})
console.log(gitLab.MyReleases.methods)
const releases = await gitLab.MyReleases.releases(new GitLab.PaginateParams({page: 2, per_page: 20}));
console.log(releases.list)
Thanks for your attention - the continuation of the api will come soon
FAQs
Integration with GitLab REST API
The npm package gitlab-restapi receives a total of 65 weekly downloads. As such, gitlab-restapi popularity was classified as not popular.
We found that gitlab-restapi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.