@yingyeothon/repository
v0.4.0
Published
An abstraction layer of repository and document.
Downloads
15
Readme
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
