New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@goofmint/growi-js

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@goofmint/growi-js

This is a SDK for [GROWI](https://growi.org/) written in node.js.

latest
npmnpm
Version
1.1.5
Version published
Maintainers
0
Created
Source

Growi node.js SDK

This is a SDK for GROWI written in node.js.

Installation

$ npm install @goofmint/growi-js

Usage

Create a client

import { GROWI } from '@goofmint/growi-js';
const growi = new GROWI({apiToken: 'YOUR_API_TOKEN'});

Initialize parameters are as follows:

ParameterDescription
apiTokenAPI token for GROWI. You can get it from the setting page of GROWI.
urlURL of GROWI. Default is http://localhost:3000.
pathEndpoint path of Growi API. Default is /.

Get root page

const page = await growi.root();
page instanceof growi.Page; // true

Get children of a page

const pages = await page.children();
pages[0] instanceof growi.Page; // true

Update page contents

page.contents('New contents');
await page.save();

Get contents of a page

const contents = await page.contents();

Create a page

const newPage = await page.create({name: 'New page'});

Remove a page

await page.remove();

Tag

Get tags of a page

const tags = await page.tags();

Add a tag to a page

await page.addTag('tag');

Remove a tag from a page

await page.removeTag('tag');

Comment

Get comments of a page

const comments = await page.comments();

Add a comment to a page

const comment = page.comment();
comment.set('comment', 'New comment');
await comment.save();

Update a comment

comment.set('comment', 'Updated comment');
await comment.save();

Remove a comment

await comment.remove();

Search pages

const result = await growi.search({q: 'keyword'});
result.pages[0] instanceof growi.Page; // true
result.total // total number of pages
result.took // time taken for search
result.hitsCount // number of hits

Search by tag

const result = await growi.searchByTag('tag');
result.pages[0] instanceof growi.Page; // true
result.total // total number of pages
result.took // time taken for search
result.hitsCount // number of hits

Attachment

Upload an attachment

const page = await growi.page({path: '/API Test'});
const fileName = 'logo.png';
const attachment = await page.upload(path.resolve("jest", fileName));
attachment // Attachment instance

Get attachments of a page

const page = await growi.page({path: '/API Test'});
const res = await Attachment.list(page);
res.attachments // array of Attachment instances
res.limit // 10
res.page // 1
res.totalDocs // 20

Check uploadable file size

const bol = await Attachment.limit(1024 * 1024 * 10);
bol // true

Find attachment

const a = await Attachment.find(attachment.id!);
a // Attachment instance

User

Get current user

const user = await growi.currentUser();

Bookmark Folder

Get bookmark folders

const bookmarkFolders = await user.bookmarkFolders();

Create a bookmark folder

const bookmarkFolder = new BookmarkFolder();
bookmarkFolder.name = 'my folder';
await bookmarkFolder.save();

Update a bookmark folder

bookmarkFolder.name = 'my folder updated';
await bookmarkFolder.save();

Remove a bookmark folder

await bookmarkFolder.remove();

Create a bookmark folder in a folder

const bookmarkFolder = new BookmarkFolder();
bookmarkFolder.name = 'Parent';
await bookmarkFolder.save();
const bookmarkFolder2 = new BookmarkFolder();
bookmarkFolder2.name = 'Child';
bookmarkFolder2.parent = bookmarkFolder;
await bookmarkFolder2.save();

Or

const bookmarkFolder = new BookmarkFolder();
bookmarkFolder.name = 'Parent';
const bookmarkFolder2 = new BookmarkFolder();
bookmarkFolder2.name = 'Child';
await bookmarkFolder.addFolder(bookmarkFolder2);

Move a bookmark folder

const bookmarkFolder3 = new BookmarkFolder();
bookmarkFolder3.name = 'New parent';
bookmarkFolder3.parent = bookmarkFolder2;
await bookmarkFolder3.save();

Fetch folder info

await bookmarkFolder.fetch();

Bookmark

Get my bookmarks

const bookmarks = await user.bookmarks();

Get bookmark info of a page

const page = await growi.root();
const info = await page.bookmarkInfo();
info.bookmarkCount // number of bookmarks
info.bookmarked    // true if the page is bookmarked by the current user
info.users         // array of users who bookmarked the page

Bookmark a page

await user.bookmark(page); // unbookmark

Unbookmark a page

await user.bookmark(page, false); // unbookmark

Check if a page is bookmarked

const bol = await user.isBookmarked(page);

Add bookmark to a folder

const folder = new BookmarkFolder();
folder.name = 'my folder';
await folder.save();
await folder.addPage(page);

License

MIT

FAQs

Package last updated on 15 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts