-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
906 additions
and
2,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: dev | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build-and-test: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
services: | ||
localstack: | ||
image: localstack/localstack:s3-latest | ||
ports: | ||
- 4566:4566 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
- run: bun install | ||
- run: bun test | ||
- run: bun run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
name: Publish | ||
name: publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
publish: | ||
name: Publish | ||
runs-on: ubuntu-latest | ||
services: | ||
localstack: | ||
image: localstack/localstack:s3-latest | ||
ports: | ||
- 4566:4566 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: yarn install | ||
- run: yarn run build | ||
- run: npm publish --access public | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
- run: bun install | ||
- run: bun test | ||
- run: bun run build | ||
- run: | | ||
echo '@ricsam:registry=https://registry.npmjs.org' >> .npmrc | ||
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc | ||
echo '//registry.npmjs.org/:always-auth=true' >> .npmrc | ||
- name: changeset publish | ||
run: npx changeset publish --access=public --registry=https://registry.npmjs.org/ | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,5 @@ index.d.ts | |
index.js | ||
nafs.d.ts | ||
nafs.js | ||
|
||
types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
example | ||
dist | ||
nodemon.json | ||
tslint.json | ||
*.test.* | ||
.prettierrc | ||
bun.lockb | ||
CONTRIBUTING.md | ||
CHANGELOG.md | ||
tsconfig.build.json | ||
tsconfig.json | ||
.github | ||
.changeset | ||
LICENSE | ||
matchers.d.ts | ||
.gitignore | ||
bunfig.toml | ||
patch-dist-dirs.sh | ||
happydom.ts | ||
renovate.json | ||
testing-library.ts | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://swc.rs/schema.json", | ||
"module": { | ||
"type": "commonjs" | ||
}, | ||
"jsc": { | ||
"target": "esnext", | ||
"parser": { | ||
"syntax": "typescript" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://swc.rs/schema.json", | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"jsc": { | ||
"target": "esnext", | ||
"parser": { | ||
"syntax": "typescript" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# nafs | ||
|
||
## 0.1.0 | ||
|
||
### Minor Changes | ||
|
||
- rewrite all code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,52 @@ | ||
# Node Active FS - nafs | ||
|
||
``` | ||
Nafs is an abstraction of the [Node fs API](https://nodejs.org/api/fs.html) where you can choose to point the fs to a remote location like s3, postgres, logstash, kibana or locally like the local filesystem or in memory. Check the [compatiblility table](#supported-file-system-methods) to see which parts of the fs API has been implemented for each backend. | ||
|
||
```bash | ||
npm install nafs | ||
yarn add nafs | ||
``` | ||
|
||
### Example | ||
|
||
```js | ||
const { nafs, expressMiddleware } = require('nafs'); | ||
const express = require('express'); | ||
|
||
const localFs = nafs('file:///tmp/dev_storage'); | ||
const remoteFs = nafs('s3://key:secret@us-east-1/bucket_name/some/path'); | ||
|
||
const app = express(); | ||
|
||
app.use('/local-files', expressMiddleware(localFs.createReadStream)); | ||
app.use('/remote-files', expressMiddleware(remoteFs.createReadStream)); | ||
|
||
app.get('/', (req, res) => { | ||
remoteFs.writeFile('/hello', 'Hello World').then(() => { | ||
res.send('saved file to s3, check it out on /remote-files/hello or /read'); | ||
}); | ||
}); | ||
app.get('/read', (req, res) => { | ||
removeFs.readFile('/hello').then((file) => { | ||
res.send(file); | ||
}); | ||
}); | ||
``` | ||
|
||
### Enable cache for remote data | ||
```js | ||
const remoteFs = nafs('s3://key:secret@us-east-1/bucket_name?cacheDir=/tmp/images'); | ||
const remoteFs = nafs('s3://key:secret@us-east-1/bucket_name'); | ||
const localFs = nafs('/tmp/some_folder'); | ||
|
||
console.time('hello'); | ||
await remoteFs.readFile('/hello') | ||
console.timeEnd('hello'); /* 70 ms */ | ||
await remoteFs.promises.writeFile('/hello', 'Hello World'); | ||
await remoteFs.promises.readFile('/hello', 'utf8'); // Hello World | ||
|
||
/* now cached */ | ||
console.time('hello'); | ||
await remoteFs.readFile('/hello') | ||
console.timeEnd('hello'); /* 2 ms */ | ||
await localFs.promises.writeFile('/hello', 'Hello World'); | ||
await localFs.promises.readFile('/hello', 'utf8'); // Hello World | ||
``` | ||
|
||
|
||
|
||
## Supported File System Methods | ||
| Method | File System | Memory | S3 | PostgreSQL | Logstash | Kibana | | ||
|---------------------|-------------|--------|-------|------------|-----------|---------| | ||
| `promises.readFile` | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | | ||
| `promises.writeFile` | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | | ||
| `promises.unlink` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.rmdir` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.mkdir` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.readdir` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.stat` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.lstat` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.chmod` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.chown` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.utimes` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.rename` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.copyFile` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.symlink` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.readlink` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.truncate` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `promises.access` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `createReadStream` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
| `createWriteStream` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | | ||
|
||
✅ - Implemented | ||
❌ - Not Implemented | ||
|
||
File System and Memory implementations are provided via memfs and linkfs, supporting full Node.js fs API compatibility. S3 implementation currently supports basic file reading and writing operations. PostgreSQL, Logstash, and Kibana implementations are planned for future development. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: '3.8' | ||
services: | ||
s3: | ||
image: localstack/localstack:s3-latest | ||
ports: | ||
- "4566:4566" |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.