-
Notifications
You must be signed in to change notification settings - Fork 2
API improvements
Andriy Mykulyak edited this page Mar 28, 2022
·
5 revisions
- no TypeScript types available
-
makeUrldoes not handle:argsinside URL -
sessionPreconditioner/sessionPostconditionermust be included in the configuration, thus creating coupling between ORM and API layers -
rawadapter does not work in an intuitive way - there's no way of specifying required / optional parameters (path / query)
Need to write code generator (say, as a NPM binary script). npx run gen-api-types config.js should generate the following:
type CreateActionRequest = {
p1: string;
p2: {
a1: number;
b2: number[];
};
};
export type <ThisModuleName>API = {
/**
* See config.ts line 124 for details.
*/
readAction: (id: string, params: { p1: string; p2?: number }) => Promise<void>;
/**
* See config.ts, line 345 for details.
*/
createAction: (params: CreateActionRequest) => Promise<void>;
};makeUrl needs to be extended (for each operation template). New implementations should analyse the url option, and extract any placeholder parameters to an array/set. At the moment of call, it should replace every occurrences of found parameters with values. The id parameter should be treated separately (because it's either the first parameter, or an attribute of the args parameter bag.
This logic should be placed inside src/operations.ts.