Skip to content

Commit

Permalink
Merge pull request #10 from OurFreeLight/dev
Browse files Browse the repository at this point in the history
fix: corrected admin routes;
  • Loading branch information
ncoonrod authored Feb 3, 2024
2 parents 251ad3a + f3dab66 commit dd0a2a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hotstaq/userroute",
"description": "A user route for HotStaq. Allows users to be created/edited/deleted securely.",
"version": "0.4.8",
"version": "0.4.9",
"main": "build/src/index.js",
"scripts": {
"test": "hotstaq --dev --env-file .env run --server-type api --api-test",
Expand Down
11 changes: 10 additions & 1 deletion src/AdminRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export class AdminRoute extends UserRoute
* @default admin
*/
methodsRequireAuthType: string;
/**
* Executes before the route is registered with the web server.
*/
onAdminPreRegisterRoute: () => Promise<void>;
/**
* The database connection.
*/
Expand All @@ -30,7 +34,7 @@ export class AdminRoute extends UserRoute

this.methodsRequireAuthType = "admin";

this.onPreRegister = async () =>
this.onAdminPreRegisterRoute = async () =>
{
let userObjectDesc: HotRouteMethodParameter = {
"type": "object",
Expand Down Expand Up @@ -115,6 +119,11 @@ export class AdminRoute extends UserRoute
]
});
};
this.onPreRegister = async () =>
{
await this.onUserPreRegisterRoute ();
await this.onAdminPreRegisterRoute ();
};
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/UserRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class UserRoute extends HotRoute
* this will call User.syncTables by default.
*/
onRegisteringRoute: ((db: HotDBMySQL) => Promise<void>);
/**
* Executes before the route is registered with the web server.
*/
onUserPreRegisterRoute: () => Promise<void>;
/**
* Test user data to use for executing tests.
*/
Expand Down Expand Up @@ -82,7 +86,7 @@ export class UserRoute extends HotRoute

return (true);
};
this.onPreRegister = async () =>
this.onUserPreRegisterRoute = async () =>
{
let userObjectDesc: HotRouteMethodParameter = {
"type": "object",
Expand Down Expand Up @@ -361,6 +365,7 @@ export class UserRoute extends HotRoute
]
});
};
this.onPreRegister = this.onUserPreRegisterRoute;
}

/**
Expand Down

0 comments on commit dd0a2a9

Please sign in to comment.