refactor: Use functional design for the authentication of apps
This commit is contained in:
26
packages/backend/src/helpers/global-variable/connection.ts
Normal file
26
packages/backend/src/helpers/global-variable/connection.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import HttpClient from '../http-client';
|
||||
import Connection from '../../models/connection';
|
||||
import { IJSONObject, IApp } from '@automatisch/types';
|
||||
|
||||
const prepareGlobalVariableForConnection = (
|
||||
connection: Connection,
|
||||
appData: IApp
|
||||
) => {
|
||||
return {
|
||||
auth: {
|
||||
set: async (args: IJSONObject) => {
|
||||
await connection.$query().patchAndFetch({
|
||||
formattedData: {
|
||||
...connection.formattedData,
|
||||
...args,
|
||||
},
|
||||
});
|
||||
},
|
||||
...connection.formattedData,
|
||||
},
|
||||
app: appData,
|
||||
http: new HttpClient({ baseURL: appData.baseUrl }),
|
||||
};
|
||||
};
|
||||
|
||||
export default prepareGlobalVariableForConnection;
|
Reference in New Issue
Block a user