npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

docbase-pdf

v0.2.2

Published

Convert DocBase Memo to pdf.

Downloads

34

Readme

docbase-pdf

Dependency Status

Overview

docbase-pdf is a library for DocBase (https://docbase.io/). You can download the article as a PDF file.

docbase-pdfは、情報共有サービスDocBase (https://docbase.io/) 用のライブラリです。 DocBase記事のPDFファイルでダウンロードすることができます。

出力サンプル

Installation

$ npm install docbase-pdf --save

Usage with TypeScript

DocBasePdfオブジェクト

  • DocBasePdfオブジェクトを使ってをDocBaseから記事を取得し、PDFを出力します
  • const docBasePdf: DocBasePdf = new DocBasePdf(DOC_BASE_API_TOKEN, TEAM_NAME);DocBasePdfオブジェクトを準備してください。
  • DOC_BASE_API_TOKENには、DocBaseのアクセストークンを設定してください。アクセスートークンの取得方法は、以下、公式マニュアルを参照してください。
  • process.env.DOC_BASE_API_TOKENを取得するには、コマンド実行時に環境変数としてDOC_BASE_API_TOKENを設定してください。
    • コマンド実行例: $ DOC_BASE_API_TOKEN=*** node .
  • TEAM_NAMEは、domainを指定してください
    • 例えば、https://hoge.docbase.ioというURLでDocBaseを利用している場合、const TEAM_NAME='hoge'です。
// An access token
const DOC_BASE_API_TOKEN = process.env.DOC_BASE_API_TOKEN;
const TEAM_NAME = 'TEAM_NAME';

const docBasePdf: DocBasePdf = new DocBasePdf(DOC_BASE_API_TOKEN, TEAM_NAME);

Sample Code For TypeScript / サンプルコード

import { DocBasePdf } from 'docbase-pdf/lib/DocBasePdf';
import { MemoCondition } from 'node-docbase-sdk/lib/conditions/MemoCondition';

// Get DocBaseAPI Token from cli.
// ex.
//   $ DOC_BASE_API_TOKEN=<DOC_BASE_API_TOKEN> node .
const DOC_BASE_API_TOKEN = process.env.DOC_BASE_API_TOKEN;
const TEAM_NAME = 'TEAM_NAME';

// クライアント生成
const docBasePdf: DocBasePdf = new DocBasePdf(DOC_BASE_API_TOKEN, TEAM_NAME);

// メモの検索キーワード
const KEYWORD = 'DOCBASE_API_TEST';

// PDF出力先ディレクトリ
const outputPath = 'docs';

// 取得するメモID
// https://${TEAM_NAME}.docbase.io/posts/${memoId}
const memoId = 347796;

async function main() {

  // メモIDを指定してPDFを取得します。
  await docBasePdf.getByMemoId(memoId, outputPath);

  // 検索条件を指定してPDFを取得します。
  const condition: MemoCondition = <MemoCondition>{};
  condition.q = KEYWORD;
  await docBasePdf.getByCondition(condition, outputPath);
}

// == Main ==
main().catch((error) => {
  console.log(error);
});