
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
collected-notes
Advanced tools
A TypeScript client for the Collected Notes API.
Install it
$ yarn add collected-notes
Import it
import { read, site, collectedNotes } from 'collected-notes';
Use it to read a single note:
const note = await read('sergiodxa', 'using-collected-notes-as-cms', 'json');
The returned note will follow the Note
interface.
const note = await read('sergiodxa', 'using-collected-notes-as-cms', 'md');
The returned note will be a string with the Markdown content.
const note = await read('sergiodxa', 'using-collected-notes-as-cms', 'txt');
The returned note will be a string with the note content as plain text, without Markdown.
Use it to get a site data with their public notes.
const siteData = await site('sergiodxa');
The return value will be an object with the format:
type SiteData = { site: Site; notes: Note[] };
To use the private API, first, get your API token from https://collectednotes.com/accounts/me/token.
Now create a new client instance with:
const cn = collectedNotes('your@email.com', 'your-api-token');
Get the list of sites of the logged-in user.
const sites = await cn.sites();
Each site of the list follows the Site
interface.
You can now get the latest notes, public and private, of a site based on their ID.
const siteId = 1;
const page = 1; // default is 1
const notes = await cn.latestNotes(siteId, page);
Each note of the list follows the Note
interface.
You can use the client to create a new note for a site of the user:
const siteId = 1; // optional, if missing the API will use your first site
const noteContent = {
body: '# Title\nContent of the note.',
visiblity: 'private',
};
const note = await cn.create(noteContent, siteId);
The returned note follows the Note
interface.
Note: This method will validate your body starts with
#
and throw a CNError instance if not.
You can use the client to update an existant note:
const siteId = 1;
const noteId = 2;
const noteContent = {
body: '# Title\nNew content of the note.',
visiblity: 'private',
};
const note = await cn.update(siteId, noteId, noteContent);
The returned note follows the Note
interface.
Note: This method will validate your body starts with
#
and throw a CNError instance if not.
You can use the client to delete a note:
const siteId = 1;
const noteId = 2;
await cn.destroy(siteId, noteId);
The returned response is the same returned by the Fetch API, you can use response.ok
or response.statusCode
to check if the delete was successful.
You can use the client to get the user data.
const user = await cn.me();
The returned user follows the User
interface.
You can use the client to reorder your notes.
const siteId = 1;
const notes: number[] = [2, 3, 1];
const orderedIds = await cn.reorder(siteId, notes);
The returned orderedIds is an array of the ids in their new order, this will be the same as the notes argument.
You can use the client to search your notes.
const siteId = 1;
const term = "new content";
const page = 1; // default is 1
const notes = await cn.search(siteId, term, page);
The private client also comes with the read
and site
methods used to get only public data. These methods are exactly the same ones and are being returned only for convenience so you could use them as:
const { site, notes } = await cn.site('sergiodxa');
const note = await cn.site('sergiodxa', 'using-collected-notes-as-cms', 'json');
You can also import the interfaces of the values returned by the API or the webhooks.
import {
ID,
Markdown,
URL,
Email,
ISODate,
NoteVisibility,
NoteFormat,
Note,
Site,
User,
EventNoteUpdated,
EventNoteCreated,
EventNoteDeleted,
EventNotesReordered,
EventNotesReordered,
Event,
} from 'collected-notes';
You can then use them to type any function in case TS is not capable to get the type implicitely, below you can see the definitions:
ID
— alias of numberMarkdown
— alias of stringURL
— alias of stringEmail
— alias of stringISODate
— alias of stringNoteVisibility
— union of stringsNoteFormat
— union of stringsNote
— The type of a noteSite
— The type of a siteUser
— The type of a userEventNoteUpdated
— The type of the note updated eventEventNoteCreated
— The type of the note created eventEventNoteDeleted
— The type of the note deleted eventEventNotesReordered
— The type of the notes reordered eventEvent
— union of other Webhook-typesFAQs
API wrapper for Collected Notes
The npm package collected-notes receives a total of 16 weekly downloads. As such, collected-notes popularity was classified as not popular.
We found that collected-notes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.