A npm package that provides access control authorized routers for Node.js projects.
The package is dedicated to be used with the @ekarpovs/authorization-repo- packages.
Supports ACL - Access Control List and RBAC - Role Based Access Control methods.
Only authorization-repo-mongo is implemented at present.
├── .github
│ ├── workflows
│ │ ├── ci.yaml
│ │ └── npm.yaml
├── .husky
│ ├── _
│ │ ├── .gitignore
│ │ └── husky.sh
│ ├── pre-commit
│ └── pre-push
├── src
│ └── index.ts
├── test
│ └── index.test.ts
├── .eslintrc
├── .gitignore
├── .prettierrc
├── .releaserc
├── babel.config.js
├── jest.config.ts
├── LICENSE
├── package-lock.json
├── package.json
├── README.md
├── tsconfig.base.json
├── tsconfig.cjs.json
└── tsconfig.esm.json
Typescript,
ESLint - a static code analysis tool,
prettier - a code formatter,
jest - a testing framework,
husky - a tool that allows to use Git hooks,
rimraf - a deep deletion module for node.
move-file-cli - a cross-platform alternative to mv for build scripts, etc.
semantic-release - automates the whole package release workflow including: determining the next version number, generating the release notes, and publishing the package
cz-conventional-changelog" - Prompts for conventional changelog standard.
Create a folder:
```bash
mkdir <new-package-name>
cd <new-package-name>
```
Clone the repository:
```bash
git clone https://github.com/ekarpovs/authorization-repo-mongo.git .
```
Install:
```bash
npm install
```
Activate Git hooks:
```bash
npm run prepare
```
Note: After the command is executed once, the Git hooks will run automatically before each commit and push.
- Packaging:
npm run pack:local
- Testing: Copy path a ekarpovs-{package-name}-0.0.0-development.tgz Install the package from root directory of a node application project:
npm i ekarpovs-{package-name}-0.0.0-development.tgz
3.1. Sign up with npm.
```bash
npm login
follow the on-screen instructions
```
- Check the contents that will be included in the published version of the package:
npx npm-packlist-cli
- See what would be done when actually running the command:
npm publish --dry-run
- publish the package to npm:
Note: --access=public is needed for scoped package (
npm publish --access=public
@scope/<package-name>
) as it's private by default. If it's not scoped and doesn't have theprivate
field set totrue
inpackage.json
it will be public as well.
The publishing process is defined via Github Actions:
- ci.yaml - build and tests.
- npm.yaml - publish the package to the npm registry.
- github.yaml - make package link to the Github registry.
The actions runs automatically after each push and pull-request.
Note: Before running the GitHub Actions, set this two environment variables:
GITHUB_TOKEN – go to GitHub and select your repository. Then go to Settings/Actions/General. You should find a section called “Workflow permissions.” Ensure that “Read and write permissions” is selected for the GITHUB_TOKEN. We need this to push the newly generated package version to the repository.
NPM_TOKEN – in your NPM account, go to the “Access Tokens” page and create a new classic token. The type of the new access token should be “Automation”. Copy the token and go to GitHub. In your repository, navigate to “Settings” and “Secrets”. Add a new repository secret named NPM_TOKEN and paste the access token you created in NPM.
Linting:
npm run lint
npm run lint:fix
Commit (use the command instead of git commit for write a conventional message):
npm run commit
Testing:
npm run test
Clean build output:
npm run clean
Build:
npm run build:esm
npm run build:cjs
npm run build
Prepack:
npm run prepack
Pack for local installation:
npm run pack:local
Prepare:
npm run prepare
Git client hooks:
.husky/pre-commit
.husky/pre-push