feat(reddit): add reddit integration
This commit is contained in:
11
packages/backend/src/apps/reddit/common/add-auth-header.ts
Normal file
11
packages/backend/src/apps/reddit/common/add-auth-header.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
3
packages/backend/src/apps/reddit/common/auth-scope.ts
Normal file
3
packages/backend/src/apps/reddit/common/auth-scope.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const authScope: string[] = ['identity', 'read', 'account', 'submit'];
|
||||
|
||||
export default authScope;
|
@@ -0,0 +1,8 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable) => {
|
||||
const { data: currentUser } = await $.http.get('/api/v1/me');
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
Reference in New Issue
Block a user