Commit 4703103f authored by 马旭烽's avatar 马旭烽

feat: git lab api 初试

parent 5d8c8b59
...@@ -3,4 +3,6 @@ ...@@ -3,4 +3,6 @@
**/node_modules **/node_modules
# 省略动态文本 # 省略动态文本
**/temp.txt **/temp.txt
\ No newline at end of file
data/**
\ No newline at end of file
import { gitlabRequest } from '../util/request';
// 不搞了,被权限限制死了,大体操作懂了
const { request } = gitlabRequest;
// 组 ID 自己建的有权限
const groupId = '246';
// 用户 ID 代表查询对应的用户,但是需要 token 进行鉴权, 找公共请求json
const userId = '161';
// 源代码里面找 project_id
const projectId = '693';
/** 获取模板 */
export const getIgnoreTemplate = () => request('/templates/gitignores', {});
/** 获取所有集成配置 */
export const getCIYAML = () => request('/templates/gitlab_ci_ymls', {});
/** 获取用户可用组资源 */
export const getGrouptIdAccessRequest = () => request(`/groups/${groupId}/access_requests`, {});
/** 获取用户可用项目资源 */
export const getProcessIdAccessRequest = () => request(`/projects/${projectId}/access_requests`, {});
/**请求用户可用组资源 */
export const postGrouptIdAccessRequest = () => request(`/groups/${groupId}/access_requests`, { method: 'post' });
/**请求用户可用项目资源 */
export const postProcessIdAccessRequest = () => request(`/projects/${projectId}/access_requests`, { method: 'post' });
\ No newline at end of file
import puppeteer from "puppeteer";
import path from "path";
import { getProcessIdAccessRequest } from './api/gitlab';
// work
// gitlab token gYgydzHDx2Cym9GBoaiG
// !async function () {
// try {
// const browser = await puppeteer.launch({
// headless: 'new',
// userDataDir: 'data',
// });
// const page = await browser.newPage();
// await page.setRequestInterception(true);
// page.on('requestfailed', ev => {
// console.log('请求错误', ev.headers(), ev.abortErrorReason())
// })
// await page.goto('http://chandao.shushangyun.com/index.php?m=effort&f=calendar', {
// referer: 'http://chandao.shushangyun.com/index.php?m=my&f=index'
// });
// console.log('hello')
// browser.close();
// } catch (error) {
// }
// }();
getProcessIdAccessRequest().then(console.log)
\ No newline at end of file
{
"name": "nodeStudy",
"version": "1.0.0",
"main": "index.js",
"repository": "ssh://git@gitlab.shushangyun.com:8122/maxufeng/nodeStudy.git",
"author": "maxufeng <unf-apqb330d4@dingtalk.com>",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn index.ts"
},
"dependencies": {
"@types/node": "16.x",
"axios": "^1.4.0",
"puppeteer": "^20.8.0",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^5.1.6"
}
}
This diff is collapsed.
import axios, { AxiosRequestConfig } from 'axios';
export const gitlabRequest = (function () {
const baseUrl = 'https://gitlab.shushangyun.com';
const apiVersion = '/api/v4';
const token = 'VCovdbJ2ZbPqy3j7shg9';
const prefixUrl = baseUrl + apiVersion;
const requestInstance = axios.create({
baseURL: prefixUrl,
method: 'Get',
headers: {
['PRIVATE-TOKEN']: token,
}
});
requestInstance.interceptors.request.use((value) => {
console.log('请求地址', value.baseURL! + value.url!)
return value;
});
requestInstance.interceptors.response.use((respose) => {
console.log('请求状态', respose.status);
console.log(respose)
return respose.data;
});
const apiWrapper = (url: string, options: AxiosRequestConfig) => {
const method = (options.method || 'get').toLowerCase();
return requestInstance.request({
url: url,
method,
})
};
return {
request: apiWrapper,
}
})();
\ No newline at end of file
This diff is collapsed.
function Get-MxfVersion {
function Get-MxfVersion {
$PSVersionTable.PSVersion
}
\ No newline at end of file
chrome.exe https://www.baidu.com/
chrome.exe https://www.baidu.com/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment