-
-
Notifications
You must be signed in to change notification settings - Fork 598
Open
Labels
type:featureNew feature or improvement of existing featureNew feature or improvement of existing feature
Description
New Feature / Enhancement Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
Current Limitation
Controllers are currently plain JS objects and their types are created and maintained separately in the CoreManager. These types are easily overlooked and aren't up to date.
Feature / Enhancement Description
Move the controllers to a separate folder /Controllers
. Converting to ES Modules will allow for type generation without having to manually update types in the CoreManager. We can then re-export the types if we need to.
Example Use Case
Controllers/SessionController.ts
export function getSession(options?: RequestOptions): Promise<ParseSession> {
const RESTController = CoreManager.getRESTController();
const session = new ParseSession();
return RESTController.request('GET', 'sessions/me', {}, options).then(sessionData => {
session._finishFetch(sessionData);
session._setExisted(true);
return session;
});
}
CoreManager.ts
import * as SessionController from './Controllers/SessionController.ts';
// Can now be deleted
type SessionController = {
getSession: (options?: RequestOptions) => Promise<ParseSession>;
};
type Config = {
...
SessionController?: SessionController;
...
};
setSessionController(controller: SessionController) {
requireMethods('SessionController', ['getSession'], controller);
config['SessionController'] = controller;
},
getSessionController(): SessionController {
return config['SessionController']!;
},
Metadata
Metadata
Assignees
Labels
type:featureNew feature or improvement of existing featureNew feature or improvement of existing feature