Skip to content

feat: mle-ts-ords-backend template #301 #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DimaNike
Copy link
Member

@DimaNike DimaNike commented Jun 5, 2025

[PR] MLE ORDS BACKEND TEMPLATE

## Description
Introduces new MLE template that uses existing mle-ts-sample as backend logic and adds ORDS configuration to expose existing logic as REST endpoint.

Fixes #301 

## Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings/errors
- [n/a] I have added tests that prove my fix is effective or that my feature works
- [n/a] New and existing unit tests pass locally with my changes

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 5, 2025
Copy link
Member

@LeonSilva15 LeonSilva15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great documentation @DimaNike, thanks!

},
},
);
const id = result.outBinds.id[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just something I didn't notice before, this attribute access is unpredictable, it assumes result.outBinds.id[0] will exist regardless the response from session.execute, optional chaining (?) is a good option here

* @returns {number} The ID of the newly created user.
*/
export function newUser(name: string): number {
const result = session.execute(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing I can't remember if was asked before: is session.execute synchronous?



--------------------------------------------------------------------------------
-- PUT ords/userc/users/:id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the previous code, looks like this should be PUT ords/userc/users/edit/:id
it's missing the edit

Comment on lines +7 to +17
it('should create a user (POST)', async () => {
const res = await fetch(`${BASE_URL}/create?name=perry`, { method: 'POST' });

expect(res.status).toBe(201);
const data = await res.json();
expect(data).toHaveProperty('id');
expect(typeof data.id).toBe('number');

createdUserId = data.id;
console.log('New user created with ID:', createdUserId);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tests are dependent on each other, which makes it fragile, although I'm not sure how we could improve this without adding too much code. All I can think of is using a beforeAll and simplifying this assertion to

it('should create a user (POST)', async () => {
    expect(createdUserId).toBeDefined();
    expect(typeof createdUserId).toBe('number');
});

and regarding the afterAll and the delition assertion... we might have to leave it as it already is since we need them to be the last test and would be a bad practice to embed a test in the afterAll, so a beforeAll looks to be all we can do. I'd like to know your opinion on this

@@ -0,0 +1,32 @@
version: '2.4'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use a more recent version instead? this one is from 2022
https://github.com/docker/compose/releases
https://github.com/docker/compose/releases/tag/v2.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants