aboutsummaryrefslogtreecommitdiff
path: root/src/background/repositories/BookmarkRepository.ts
blob: 0d2a1fc8fbb3eec03c75f5ccc767989e539c75c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { injectable } from 'tsyringe';

@injectable()
export default class BookmarkRepository {
  async create(
    title: string, url: string
  ): Promise<browser.bookmarks.BookmarkTreeNode> {
    const item = await browser.bookmarks.create({
      type: 'bookmark',
      title,
      url,
    });
    if (!item) {
      throw new Error('Could not create a bookmark');
    }
    return item;
  }
}