routing-controllers
routing-controllers copied to clipboard
feat: export type 'CurrentUserChecker' & 'AuthorizationChecker'
Description
Export type 'CurrentUserChecker' and 'AuthorizationChecker' in the entry file to make it easier to import related types, Like this:
import Koa from "koa";
import { useKoaServer } from "routing-controllers";
import { authorizationChecker, currentUserChecker } from "./helpers";
useKoaServer(app, {
cors: {
credentials: true,
},
routePrefix: "/api",
controllers: [CasController, UserController],
middlewares: [ErrorHandlerMiddleware],
defaults: {
nullResultCode: 200,
undefinedResultCode: 200,
paramOptions: {
required: true,
},
},
defaultErrorHandler: false,
authorizationChecker,
currentUserChecker,
});
app.listen(8080);
import type { AuthorizationChecker } from "routing-controllers";
//import type { AuthorizationChecker } from "routing-controllers/types/AuthorizationChecker";
export const authorizationChecker: AuthorizationChecker = async (action, permissions) => {
// ...
};
Checklist
- [x] the pull request title describes what this PR does (not a vague title like
Update index.md
) - [x] the pull request targets the default branch of the repository (
develop
) - [x] the code follows the established code style of the repository
-
npm run prettier:check
passes -
npm run lint:check
passes
-
- [x] tests are added for the changes I made (if any source code was modified)
- [x] documentation added or updated
- [x] I have run the project locally and verified that there are no errors
Fixes
fixes #[issue number], fixes #[issue number]