@bluelibs/security-mongo-bundle
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

BlueLibs SECURITY-MONGO-BUNDLE

In this bundle we're overriding the persistence layers from SecurityBundle to make them work with MongoBundle.

Installation

npm i -S @bluelibs/security-bundle @bluelibs/security-mongo-bundle
import { SecurityBundle } from "@bluelibs/security-bundle";
import { SecurityMongoBundle } from "@bluelibs/security-mongo-bundle";

kernel.addBundle(
  new SecurityBundle({
    // options
  }),
  // Order doesn't really matter.
  new SecurityMongoBundle()
);

Overriding

You have the option to make changes to your collections, for example if you user is linked to other collections or you simply want a different collectioName:

import {
  UsersCollection,
  PermissionsCollection,
} from "@bluelibs/security-mongo-bundle";
import { IUser } from "@bluelibs/security-bundle";

// We make the type behave with all of our needs
interface IAppUser extends IUser {
  profileId: ObjectID;
}

class AppUsersCollection extends UsersCollection<IAppUser> {
  static collectionName = "User"; // override it, by default it's "users"

  static links = {
    profile: {
      collection: () => ProfilesCollection,
      field: "profileId",
    },
  };

  static indexes = [
    {
      key: {
        profileId: 1,
      },
    },
  ];
}
new SecurityMongoBundle({
  usersCollection: AppUsersCollection,
});

Support

This package is part of BlueLibs family. If you enjoy this work please show your support by starring the main package. If not, let us know what can we do to deserve it, our feedback form is here

Dependents (0)

Package Sidebar

Install

npm i @bluelibs/security-mongo-bundle

Weekly Downloads

210

Version

1.2.4

License

MIT

Unpacked Size

53 kB

Total Files

45

Last publish

Collaborators

  • theodordiaconu