Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/svtslv/nestjs-webdav

WebDAV module for Nest
https://github.com/svtslv/nestjs-webdav

nest nestjs nextcloud storage webdav

Last synced: 2 months ago
JSON representation

WebDAV module for Nest

Awesome Lists containing this project

README

        

# NestJS WebDAV

NPM Version
Package License

## 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