An error occurred while loading the file. Please try again.
gitlab.ts 1.34 KiB
import axios from 'axios'
const gitlab = {
  getProjects: async function (perPage: number, idAfter: number) {
    try {
      const projects = await axios({
        method: 'get',
        url: 'https://transfer.hft-stuttgart.de/gitlab/api/v4/projects?visibility=public&pagination=keyset&per_page=' + String(perPage) + '&order_by=id&sort=asc&id_after=' + String(idAfter)
      })
      const data = projects.data
      const reposArr = []
      const pagesArr = []
      for (let i = 0; i < data.length; i++) {
        // skip template project
        if (data[i].name === 'page_basic' || data[i].name === 'generic' || data[i].name === 'simple_raw' || data[i].name === 'simple_thesis') {
          continue
        } else if (data[i].tag_list.includes('website')) {
          pagesArr.push(data[i])
        } else {
          reposArr.push(data[i])
      return {
        error: false,
        data: [reposArr, pagesArr]
    } catch (err) {
      return {
        error: true,
        data: err
  getLatestPipelineStatus: async function (projectId: number) {
    return await axios({
      method: 'get',
      url: 'https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/' + String(projectId) + '/pipelines'
      .then(res => res.data[0].status)
      .catch(err => console.error(err.response))
export { gitlab }