# local-file-access-js

This is a simple server that allows you to access local NWB files using Neurosift.

## Instructions

**Prerequisites:**

* A recent version of NodeJS (tested with v18.16.1)

**Step 1: Prepare a directory where you will store your .nwb files**

```bash
export NWB_DIR=/path/to/your/nwb/files
```

**Step 2: Install the dependencies and run the server**

```bash
# cd to this directory
cd experimental-local-file-access

npm install
npm run start $NWB_DIR
```

**Step 3: Open the neurosift web app in your browser and point to an nwb file**

```bash
https://neurosift.app/?p=/nwb&url=http://localhost:61762/files/testing.nwb
```

This will load the nwb file from `$NWB_DIR/testing.nwb`

## Using a different port

By default, the port is 61762. You can change this by setting the `PORT` environment variable in the run command:

```bash
PORT=12345 npm run start $NWB_DIR
```

## Security considerations

This server will expose the contents of files in the directory you specify to anyone who can access the server. This does not include hidden files (those starting with "."). This is not a problem if you are running the server on your local machine and only accessing it from your local machine. However, if you are running the server on a machine that is accessible from the internet, you should take precautions to ensure that only authorized users can access the server, if you have sensitive files.

There is also a possibility that websites you visit could get read access to your files. However, the configuration will prevent this from happening unless the website is being served from the allowed domains (neurosift.app and localhost:3000).