CATALEPSY
Catalepsy is a medium-read-only wrapper that lets you get all user (public) posts, also get a single post in raw format, markdown or html
Try it online
just head to Runkit and click run
Install
yarn add catalepsy
or
npm install -S catalepsy
Usage
const Catalepsy = const catalepsy = siteUrl: 'http://test.com/' // defaults to https://medium.com/ cdn: 'https://amazontest.com/' // defaults to https://cdn-images-1.medium.com/max/1600/ cacheInMinutes: 5 // defaults to 1 logger: consolelog // put here your favourite logger defaults to no-logs
Exposed methods
getPosts Async function({username, limit})
username is the medium user's username. This is required
limit is the number of latest post to fetch, defaults to 10
getPost Async function({ username, slug, format })
username is the medium user's username. This is required
slug is the desired post slug (you can get that from getPosts). This is required
format is the result format, defaults to html
You can set one of three possible format options:.
raw
: will return a JSON format just like medium returns itmarkdown
: will return the post in markdown formathtml
: will return the post in html format
Examples:
const getAllUserPosts = async { const status data = await catalepsy // status is an HTTP Status code (200 or 500) // data is a JSON file with `posts` and `user`} const getPost = async { const data: html = await catalepsy // HTML with the post const data: raw = await catalepsy // raw is the JSON from medium const data: markdown = await catalepsy // markdown is the post in markdown format}
Develop
Must follow standard.js rules and keep test coverage over 90% to be able to commit
Testing
Just run yarn test
coverage should be 100%