Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cto4/rentry-co
A Full CRUD super-lite rentry.co wrapper with typescript support and no-dependencies library.
https://github.com/cto4/rentry-co
api express library markdown rentry-co
Last synced: about 17 hours ago
JSON representation
A Full CRUD super-lite rentry.co wrapper with typescript support and no-dependencies library.
- Host: GitHub
- URL: https://github.com/cto4/rentry-co
- Owner: cto4
- License: mit
- Created: 2024-08-22T23:11:28.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-09-19T00:00:44.000Z (9 days ago)
- Last Synced: 2024-09-23T06:02:33.062Z (5 days ago)
- Topics: api, express, library, markdown, rentry-co
- Language: TypeScript
- Homepage: https://cto4.github.io/rentry-co/
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rentry-Co
A Full CRUD super-lite rentry.co wrapper with typescript support and no-dependencies library.
## Features
- create entries
- read entries
- update entries
- delete entries
- typescript support
- built-in express routes
- no-dependencies## Installation
```sh
npm i rentry-co
```## Usage
Import the library
```ts
// src/lib/rentry.js// CommonJS
const RentryCo = require("rentry-co");
// ESM
import RentryCo from "rentry-co";/*=============================*/
// Use It
const rentry = new RentryCo();
export default rentry;
```### Create a new entry
```ts
async function test() {
// id is optional, skip for random id
var res = await rentry.create({
id: "",
content: "Hello World",
});
console.log(res);
}
```Output :
> save token & id for feature use !
```json
{ "status": "200", "token": "abxx12xx", "id": "abc123" }
```### Read entry
```ts
async function test() {
var res = await rentry.read({ id: "" });
console.log(res);
}
```Output :
```json
{ "status": "200", "content": "## Hi\nHello World" }
```### Update an existing entry
```ts
async function test() {
var res = await rentry.update({
id: "",
token: "",
content: "## Hi\nHello World",
});
console.log(res);
}
```Output :
```json
{ "status": "200", "content": "OK" }
```### Delete entry
```ts
async function test() {
var res = await rentry.delete({
id: "",
token: "",
});
console.log(res);
}
```Output :
```json
{ "status": "200", "content": "OK" }
```### Express routes
Use built-in expres routes from `RentryCoExpress` to create api.
> note: `body-parser`, `cors` are required, install with `npm i body-parser cors`
```ts
import express from "express";
import bodyParser from "body-parser";
import cors from "cors";import RentryCoExpress from "./index";
const app = express();
app.use(bodyParser.text());
app.use(cors());app.use("/api/rentry", RentryCoExpress);
app.listen(3000, () => {
console.log("server started at: http://localhost:3000");
});
```## License
[MIT License](https://github.com/cto4/rentry-co/blob/main/LICENSE)