https://github.com/magiclen/node-datalith
Datalith is a file management system powered by SQLite for metadata storage and the file system for file storage. This library can help you conmunicate with Datalith in Node.js.
https://github.com/magiclen/node-datalith
datalith nodejs typescript
Last synced: 4 months ago
JSON representation
Datalith is a file management system powered by SQLite for metadata storage and the file system for file storage. This library can help you conmunicate with Datalith in Node.js.
- Host: GitHub
- URL: https://github.com/magiclen/node-datalith
- Owner: magiclen
- License: mit
- Created: 2024-09-05T09:34:27.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-23T10:41:38.000Z (about 1 year ago)
- Last Synced: 2025-08-09T12:09:06.829Z (10 months ago)
- Topics: datalith, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 366 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Datalith for Node.js
==========
[](https://github.com/magiclen/node-datalith/actions/workflows/ci.yml)
[Datalith](https://github.com/magiclen/datalith) is a file management system powered by SQLite for metadata storage and the file system for file storage. This library can help you conmunicate with Datalith in Node.js.
## Usage
```typescript
import { createReadStream } from "node:fs";
import { readFile } from "node:fs/promises";
import { buffer } from "node:stream/consumers";
import { Datalith } from "node-datalith";
const API_PREFIX = "http://127.0.0.1:1111";
const FILE_PATH = "tests/data/image.png";
const datalith = new Datalith(API_PREFIX);
const resource = await datalith.putResource({ fileStream: createReadStream(FILE_PATH) });
const file = await datalith.getResource(resource.id));
const data = await buffer(file.data);
const image = await datalith.putImage({ fileStream: createReadStream(FILE_PATH), maxWidth: 128 });
const originalImageFile = await datalith.getImage(image.id, { resolution: "original" });
const thumbnailImageFile = await datalith.getImage(image.id, { resolution: "1x" });
```
## License
[MIT](LICENSE)