Git Product home page Git Product logo

authorization-checker's Introduction

Authorization Checker

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.

Version Documentation Maintenance License: MIT

The project file system tree:

├── .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

The project infrastructure

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.

Get started

1. Create a package project

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.

2. Write the package code , pack and tests locally:

  • 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. Prepare to publish the package:

3.2. Sign in with your npm account in the terminal:
```bash
npm login 
follow the on-screen instructions
```

4. Publish the package:

4.1. Manual publishing:
  • 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:
    npm publish --access=public
    Note: --access=public is needed for scoped package (@scope/<package-name>) as it's private by default. If it's not scoped and doesn't have the private field set to true in package.json it will be public as well.
4.2 Automated publishing:
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.

Usage the commands from the command line during the development:

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

authorization-checker's People

Contributors

ekarpovs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.