2018-08-07 14:46:54 -06:00
|
|
|
import { flow } from 'lodash';
|
|
|
|
import { API as GitlabAPI } from 'netlify-cms-backend-gitlab';
|
|
|
|
import { unsentRequest, then } from 'netlify-cms-lib-util';
|
2018-06-11 19:03:43 -07:00
|
|
|
|
|
|
|
export default class API extends GitlabAPI {
|
|
|
|
constructor(config) {
|
|
|
|
super(config);
|
|
|
|
this.tokenPromise = config.tokenPromise;
|
|
|
|
this.commitAuthor = config.commitAuthor;
|
2018-08-07 14:46:54 -06:00
|
|
|
this.repoURL = '';
|
2018-06-11 19:03:43 -07:00
|
|
|
}
|
|
|
|
|
2018-08-07 14:46:54 -06:00
|
|
|
authenticateRequest = async req =>
|
|
|
|
unsentRequest.withHeaders(
|
|
|
|
{
|
|
|
|
Authorization: `Bearer ${await this.tokenPromise()}`,
|
|
|
|
},
|
|
|
|
req,
|
|
|
|
);
|
2018-06-11 19:03:43 -07:00
|
|
|
|
2018-08-07 14:46:54 -06:00
|
|
|
request = async req =>
|
|
|
|
flow([this.buildRequest, this.authenticateRequest, then(unsentRequest.performRequest)])(req);
|
2018-06-11 19:03:43 -07:00
|
|
|
|
2018-08-07 14:46:54 -06:00
|
|
|
hasWriteAccess = () => Promise.resolve(true);
|
2018-06-11 19:03:43 -07:00
|
|
|
}
|