open-index/open-npm huggingface dataset:
npm package: @smartnewbs/feathersjs-hook-users
Description: Feathersjs hooks for the user service
Author: Philippe Guilbault
Latest version: 1.1.2


# @smartnewbs/feathersjs-hook-users
![License](https://img.shields.io/npm/l/@smartnewbs/feathersjs-hook-users.svg)
![Version](https://img.shields.io/npm/v/@smartnewbs/feathersjs-hook-users.svg)
![Node](https://img.shields.io/node/v/@smartnewbs/feathersjs-hook-users.svg)
[![Coverage Status](https://coveralls.io/repos/bitbucket/smartnewbs/feathersjs-hook-users/badge.svg?branch=master)](https://coveralls.io/bitbucket/smartnewbs/feathersjs-hook-users?branch=master)

This lib is for [Feathersjs](https://github.com/feathersjs/feathers) as utility hooks.

## Installation
```bash
npm install @smartnewbs/featherjs-hook-users --save
```

## firstUserIsRole
The hook will modify `hook.data.role` with the specified role only if its the first entry in the `users` service.
It is meant to be only used as a before create hook in your `users.hooks.js`:
```javascript
const { firstUserIsRole } = require('@smartnewbs/feathersjs-hook-users');
module.exports = {
  before: {
    create: [ firstUserIsRole('ROLE_ADMIN') ]
  }
}
```

## restrictPropertyByRoles
The hook will check the authenticated user's role (`hook.params.user.role`) against the roles
specified. It is meant to be only used as a before hook for the methods create, update and patch.  
```javascript
const { restrictPropertyByRoles } = require('@smartnewbs/feathersjs-hook-users');
module.exports = {
  before: {
    create: [ restrictPropertyByRoles('status', ['ROLE_ADMIN']) ],
    update: [ restrictPropertyByRoles('status', ['ROLE_ADMIN']) ],
    patch: [ restrictPropertyByRoles('status', ['ROLE_ADMIN']) ]
  }
}
```

## extractGoogleProfile
The hook is mean to extract Google OAuth profile and associate the properties to the user model.
```javascript
hook.data.email = hook.data.google.profile.emails[0].value;
hook.data.name = hook.data.google.profile.displayName;
hook.data.avatar = hook.data.google.profile.photos[0].value;
```
It is meant to be a before hook for the method create.
```javascript
const { extractGoogleProfile } = require('@smartnewbs/feathersjs-hook-users');
module.exports = {
  before: {
    create: [ extractGoogleProfile ]
  }
}
```
npm package: @smartnewbs/gcp-k8s
Description: Utility lib for Google Cloud Platform & Kubernetes
Author: Philippe Guilbault
Latest version: 1.0.4

# Google Cloud Platform & Kubernetes cluster
The library is meant to be used in concert with [Atlassian Bitbucket piplines](https://bitbucket.org/product/features/pipelines).

Although it is meant to only deploy the "app" and not its database, it can be refined to any infrastructure need.

It expect certain environment variables to be set
```bash
GCLOUD_API_KEYFILE=./gcloud-api-key.json
GCLOUD_PROJECT_ID=boilerplates-190517

GCLOUD_CLUSTER=master
GCLOUD_CLUSTER_REGION=northamerica-northeast1

BITBUCKET_COMMIT=sfn24d9823i953id98
BITBUCKET_BRANCH=BOIL-432

GCLOUD_REGISTRY_REGION=us.gcr.io
GCLOUD_IMAGE_NAME=feathersjs
```

It also expect that the *IAM & Admin* to have the following roles:
```
Compute Engine -> Compute Viewer
Kubenetes Engine -> Kubernetes Engine Admin
Service Accounts -> Service Account User
Storage -> Storage Admin
```