1.0.5 • Published 4 months ago

ams-ssk v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

AMS (Asset Management System) Library

A NestJS library for file management and asset operations that can be integrated into any NestJS application.

Features

  • File and folder management (create, read, update, delete)
  • File uploads and downloads
  • File metadata operations
  • JSON file operations with path-based queries
  • File thumbnails and previews
  • Folder archiving
  • File search capabilities
  • File sharing links

Installation

npm install ams

Usage

Basic Usage

In your NestJS application, import the FileModule into your AppModule:

import { Module } from '@nestjs/common';
import { FileModule } from 'ams';

@Module({
  imports: [
    FileModule.register(), // Use default configuration
  ],
})
export class AppModule {}

Configuration Options

You can customize the module's behavior by using the forRoot() method:

import { Module } from '@nestjs/common';
import { FileModule } from 'ams';

@Module({
  imports: [
    FileModule.forRoot({
      storagePath: './custom-uploads',
      maxFileSize: 10 * 1024 * 1024, // 10MB
      allowedFileTypes: ['image/jpeg', 'image/png', 'application/pdf'],
    }),
  ],
})
export class AppModule {}

Using as a Global Module

You can also make the module available globally:

import { Module } from '@nestjs/common';
import { FileModule } from 'ams';

@Module({
  imports: [
    FileModule.forRootGlobal({
      storagePath: './global-uploads',
    }),
  ],
})
export class AppModule {}

Using the FileService

Once you've imported the module, you can inject the FileService into your controllers or services:

import { Controller, Get, Inject } from '@nestjs/common';
import { FileService } from 'ams';

@Controller('my-files')
export class MyFilesController {
  constructor(private readonly fileService: FileService) {}

  @Get('folders')
  async listAllFolders() {
    return this.fileService.listFolders();
  }
  
  @Get('recent')
  async getRecentFiles() {
    return this.fileService.getRecentFiles();
  }
}

Available Methods

The FileService provides many methods for file and folder operations:

  • listFolders(): List all folders
  • getFolderDetails(folder, page, limit): Get paginated folder contents
  • createFolder(folderName): Create a new folder
  • deleteFolder(folder): Delete an empty folder
  • uploadFiles(folder, files, filenameQuery): Upload files to a folder
  • downloadFile(folder, filename, res): Download a specific file
  • getFileMetadata(folder, filename): Get metadata for a file
  • moveFile(folder, filename, body): Move or rename a file
  • copyFile(folder, filename, body): Copy a file
  • deleteFile(folder, filename): Delete a file
  • getJsonFile(folder, filename): Get content of a JSON file
  • queryJsonFile(folder, filename, query): Query a JSON file using path notation
  • ... and many more

API Documentation

After installing and configuring the module, you can access the Swagger documentation for the API endpoints at:

http://your-app-url/api-docs

License

MIT

Resources

Check out a few resources that may come in handy when working with NestJS:

  • Visit the NestJS Documentation to learn more about the framework.
  • For questions and support, please visit our Discord channel.
  • To dive deeper and get more hands-on experience, check out our official video courses.
  • Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
  • Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
  • Need help with your project (part-time to full-time)? Check out our official enterprise support.
  • To stay in the loop and get updates, follow us on X and LinkedIn.
  • Looking for a job, or have a job to offer? Check out our official Jobs board.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago