Files
nodejs-fm/README.md

122 lines
2.7 KiB
Markdown
Raw Normal View History

2019-05-19 10:47:08 +05:30
# nodejs-fm
2019-05-24 11:04:51 +05:30
2020-12-25 13:18:56 +05:30
![Node.js CI](https://github.com/chrisvrose/nodejs-fm/workflows/Node.js%20CI/badge.svg)
2019-05-24 11:04:51 +05:30
2019-05-24 12:04:21 +05:30
A simple file manager for managing files on a remote fs using Node.
2019-05-19 10:47:08 +05:30
2020-09-25 10:16:54 +05:30
![Sample Image](https://github.com/chrisvrose/chrisvrose.github.io/raw/gh-pages/static/projects/screenshots/nodejs-fm.png)
2019-09-14 19:51:49 +05:30
2020-12-05 10:53:41 +05:30
Dependencies: `express` `body-parser` `@fortawesome/fontawesome-free` `jquery` `connect-busboy`,`morgan`
Dependencies(testing): `chai` `mocha` `chai-http`
2019-05-19 10:47:08 +05:30
### Why
Personal requirement.
2019-05-27 14:21:36 +05:30
Because of this, only renaming/moving(only in same fs, due to `fs.rename()`) is available, and uploading/downloading.
No authentication, as it is based on a small local server, and the major way of accessing it, is ssh.
2019-05-19 10:47:08 +05:30
2020-12-05 10:53:41 +05:30
## TOC
- [nodejs-fm](#nodejs-fm)
- [Why](#why)
- [TOC](#toc)
- [Usage](#usage)
- [Using settings.json](#using-settingsjson)
- [Server requests](#server-requests)
- [Credit](#credit)
- [Checklist](#checklist)
- [Dev Checklist](#dev-checklist)
2019-05-24 12:04:21 +05:30
## Usage
2020-12-05 10:53:41 +05:30
Use `settings.json` and point it to a valid path, and select a required port. Default `8080`. Refer [how to use settings.json](#using-settingsjson).
2019-05-24 12:04:21 +05:30
2019-09-15 13:23:23 +05:30
*_Travis only checks the backend, which is a separate entity._*
2019-05-24 12:04:21 +05:30
2019-05-27 14:21:36 +05:30
For running it:
2020-12-05 10:53:41 +05:30
```bash
2019-05-27 14:21:36 +05:30
# Clone repo
git clone https://github.com/chrisvrose/nodejs-fm.git
# Move into repo folder
cd nodejs-fm/
# Setup the project
npm i
# Your own config, start with settings.json
#...
# Start the server
npm start
2020-12-05 11:38:52 +05:30
# Tests
npm test
2019-05-27 14:21:36 +05:30
```
2020-12-05 10:53:41 +05:30
### Using settings.json
You need to have a `settings.json` in the project directory. A sample has been provided for usage.
|Key |Type |Default |Desc |
|:---------|:-------:|----------:|:-----------------------|
|dirname |`string` |`./sandbox`|Directory to serve |
|showHidden|`boolean`|false |Show hidden files |
|port |`number` |8080 |Webserver listening port|
2019-05-27 14:21:36 +05:30
### Server requests
2019-05-24 12:04:21 +05:30
Requests:
2020-12-05 10:53:41 +05:30
```json
2019-05-24 12:04:21 +05:30
{
2020-12-05 10:53:41 +05:30
"loc": "<valid location>"
2019-05-24 12:04:21 +05:30
}
```
2019-05-24 14:46:30 +05:30
2019-05-27 15:46:27 +05:30
Responses (View directory):
2019-05-24 12:04:21 +05:30
2020-12-05 10:53:41 +05:30
```json
2019-05-24 12:04:21 +05:30
{
2020-12-05 10:53:41 +05:30
"loc": "<location>",
2020-12-05 11:38:52 +05:30
"back": "<location>|null",
2020-12-05 10:53:41 +05:30
"contents":[
2019-05-24 12:04:21 +05:30
{
2020-12-05 10:53:41 +05:30
"name":"<filename>",
"path":"<location>",
2020-12-05 11:38:52 +05:30
"isDir": "true|false"
2019-05-24 12:04:21 +05:30
},
]
}
```
2019-05-27 15:46:27 +05:30
Responses(Rename/Move Success,Upload)
2020-12-05 10:53:41 +05:30
```json
2019-05-27 15:46:27 +05:30
{
2020-12-05 10:53:41 +05:30
"loc":"<new location>"
2019-05-27 15:46:27 +05:30
}
```
2019-05-24 12:04:21 +05:30
## Credit
2019-05-24 11:35:33 +05:30
2019-05-19 18:48:50 +05:30
- Samuel Thornton: [Material Design Box Shadows]("https://codepen.io/sdthornton/pen/wBZdXq")
2019-05-24 14:41:30 +05:30
- Chris Pratt: [File Download via Ajax]('https://codepen.io/chrisdpratt/pen/RKxJNo')
2019-05-24 11:27:55 +05:30
- StackOverflow: Troubleshooting errors
2019-09-14 19:53:32 +05:30
- Google: All knowing
2020-12-05 10:53:41 +05:30
## Checklist
- [x] Folder Traversal
- [X] File Downloads
- [X] File Moving
- [X] Upload
## Dev Checklist
- [x] Folder Traversal
- [X] File Downloads
- [X] File Moving
- [X] Upload
- [X] Integration with frontend