@yingyeothon/repository
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Repository layer

An abstraction layer for repository and document.

Usage

It provides simple needed methods for repository like get, set and delete so we can write general codes working with this persistent features like this.

import { Repository } from "@yingyeothon/repository";

interface Credential {
  id: string;
  pw: string;
}

export class Authorizer {
  constructor(private readonly repo: Repository) {}

  public async login(id: string, pw: string) {
    const tuple = await this.repo.get<Credential>(id);
    return tuple && tuple.pw === pw;
  }
}

It provides the only interface so please use actual implementation like @yingyeothon/repository-s3.

import { S3Repository } from "@yingyeothon/repository-s3";

const authorizer = new Authorizer(
  new S3Repository({
    bucketName: process.env.BUCKET_NAME,
    prefix: "__credential__/",
  })
);

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @yingyeothon/repository

Weekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

20 kB

Total Files

24

Last publish

Collaborators

  • lacti