feat: Implement auth serializer
This commit is contained in:
9
packages/backend/src/serializers/auth.js
Normal file
9
packages/backend/src/serializers/auth.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const authSerializer = (auth) => {
|
||||
return {
|
||||
fields: auth.fields,
|
||||
authenticationSteps: auth.authenticationSteps,
|
||||
reconnectionSteps: auth.reconnectionSteps,
|
||||
};
|
||||
};
|
||||
|
||||
export default authSerializer;
|
17
packages/backend/src/serializers/auth.test.js
Normal file
17
packages/backend/src/serializers/auth.test.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import App from '../models/app';
|
||||
import authSerializer from './auth';
|
||||
|
||||
describe('authSerializer', () => {
|
||||
it('should return auth data', async () => {
|
||||
const auth = await App.findAuthByKey('deepl');
|
||||
|
||||
const expectedPayload = {
|
||||
fields: auth.fields,
|
||||
authenticationSteps: auth.authenticationSteps,
|
||||
reconnectionSteps: auth.reconnectionSteps,
|
||||
};
|
||||
|
||||
expect(authSerializer(auth)).toEqual(expectedPayload);
|
||||
});
|
||||
});
|
@@ -6,6 +6,7 @@ import appAuthClientSerializer from './app-auth-client.js';
|
||||
import flowSerializer from './flow.js';
|
||||
import stepSerializer from './step.js';
|
||||
import appSerializer from './app.js';
|
||||
import authSerializer from './auth.js';
|
||||
|
||||
const serializers = {
|
||||
User: userSerializer,
|
||||
@@ -16,6 +17,7 @@ const serializers = {
|
||||
Flow: flowSerializer,
|
||||
Step: stepSerializer,
|
||||
App: appSerializer,
|
||||
Auth: authSerializer,
|
||||
};
|
||||
|
||||
export default serializers;
|
||||
|
Reference in New Issue
Block a user