Skip to content
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

Convert CoreManager and controllers to ES modules #2495

Open
3 tasks done
dplewis opened this issue Mar 12, 2025 · 1 comment
Open
3 tasks done

Convert CoreManager and controllers to ES modules #2495

dplewis opened this issue Mar 12, 2025 · 1 comment

Comments

@dplewis
Copy link
Member

dplewis commented Mar 12, 2025

New Feature / Enhancement Checklist

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']!;
},
Copy link

parse-github-assistant bot commented Mar 12, 2025

🚀 Thanks for opening this issue! We are excited about your ideas for improvement!

@dplewis dplewis changed the title Convert CoreManager and controllers to static classes Convert CoreManager and controllers to ECMAScript modules Mar 12, 2025
@dplewis dplewis changed the title Convert CoreManager and controllers to ECMAScript modules Convert CoreManager and controllers to ES modules Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant