https://github.com/svtslv/nestjs-webdav
WebDAV module for Nest
https://github.com/svtslv/nestjs-webdav
nest nestjs nextcloud storage webdav
Last synced: 8 months ago
JSON representation
WebDAV module for Nest
- Host: GitHub
- URL: https://github.com/svtslv/nestjs-webdav
- Owner: svtslv
- Created: 2020-02-29T03:32:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T01:16:41.000Z (about 2 years ago)
- Last Synced: 2025-04-12T23:08:53.958Z (about 1 year ago)
- Topics: nest, nestjs, nextcloud, storage, webdav
- Language: TypeScript
- Size: 305 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NestJS WebDAV
## Table of Contents
- [Description](#description)
- [Installation](#installation)
- [Examples](#examples)
- [License](#license)
## Description
Integrates WebDAV with Nest
## Installation
```bash
npm install nestjs-webdav webdav
```
You can also use the interactive CLI
```sh
npx nestjs-modules
```
## Examples
### WebDAV-CLI
```bash
npx webdav-cli --username=username --password=password
```
### NextCloud
```bash
docker run \
-e SQLITE_DATABASE=nextcloud \
-e NEXTCLOUD_ADMIN_USER=admin \
-e NEXTCLOUD_ADMIN_PASSWORD=password \
-p 8080:80 \
nextcloud
```
### WebDAVModule.forRoot(options, connection?)
```ts
import { Module } from '@nestjs/common';
import { WebDAVModule } from 'nestjs-webdav';
import { AppController } from './app.controller';
@Module({
imports: [
WebDAVModule.forRoot({
config: {
endpoint: 'http://127.0.0.1:1900',
username: 'username',
password: 'password',
},
}),
WebDAVModule.forRoot({
config: {
endpoint: 'http://localhost:8080/remote.php/dav/files/admin/',
username: 'admin',
password: 'password',
},
}, 'nextCloud'),
],
controllers: [AppController],
})
export class AppModule {}
```
### WebDAVModule.forRootAsync(options, connection?)
```ts
import { Module } from '@nestjs/common';
import { WebDAVModule } from 'nestjs-webdav';
import { AppController } from './app.controller';
@Module({
imports: [
WebDAVModule.forRootAsync({
useFactory: () => ({
config: {
endpoint: 'http://127.0.0.1:1900',
username: 'username',
password: 'password',
},
}),
}),
WebDAVModule.forRootAsync({
useFactory: () => ({
config: {
endpoint: 'http://localhost:8080/remote.php/dav/files/admin/',
username: 'admin',
password: 'password',
},
}),
}, 'nextCloud'),
],
controllers: [AppController],
})
export class AppModule {}
```
### InjectWebDAV(connection?)
```ts
import { Controller, Get, } from '@nestjs/common';
import { InjectWebDAV, WebDAV } from 'nestjs-webdav';
@Controller()
export class AppController {
constructor(
@InjectWebDAV() private readonly webDAV: WebDAV,
@InjectWebDAV('nextCloud') private readonly nextCloud: WebDAV,
) {}
@Get()
async getHello() {
return {
webdavCli: await this.webDAV.getDirectoryContents('/'),
nextCloud: await this.nextCloud.getDirectoryContents('/'),
}
}
}
```
## License
MIT