NestJS GitLab Service
NestJS GitLab Service
fs.writeFileSync(zipPath, response.data);
fs.unlinkSync(zipPath);
} catch (error) {
console.error(`Error cloning project with id ${projectId}: ${error.message}`);
throw error;
}
}
}
This service takes in the project ID and the path where you want to clone the project as arguments. It then
makes a GET request to the GitLab API to download the project archive as a zip file, saves it to disk, unzips
it, and deletes the zip file. If there is an error during this process, it logs an error message and throws the
error.
4. Finally, you can use this service in any other module or controller in your application by importing the
`GitlabModule` and injecting the `GitlabService`:
@Controller()
export class AppController {
constructor(private readonly gitlabService: GitlabService) {}
@Get()
async cloneProject() {
const projectId = 1234; // replace with the ID of the project you want to clone
const clonePath = '/path/to/clone'; // replace with the path where you want to clone the pro