A robust NestJS microservice for secure, automated file exchange between organizations using FTP. It supports file upload, download, listing, and health monitoring, with a focus on reliability and extensibility.
- Encrypts files before uploading to FTP, stores encrypted files locally, then uploads to CRA FTP
- Decrypts files after downloading from CRA FTP, stores encrypted files locally, and returns decrypted file to client
- Upload files to remote FTP servers
- Delivery Status end point to check file status
- List local and remote files
- Download files from remote FTP servers
- Download files from local servers
- Health check endpoints for FTP connectivity
- Configurable via environment variables
- API documentation via Swagger
This service is built with NestJS and follows a modular structure:
- Controllers: Handle HTTP requests (upload, download, list, health, etc.)
- Services:
- Handle FTP logic and file operations
- Encrypt files before upload, decrypt after download
- DTOs & Interfaces: Define request/response schemas
- Config: Loads FTP and server settings from environment variables
Set the following environment variables (e.g., in a .env file or your deployment environment):
PORT=3000
FTP_HOST=<ftp-server-host>
FTP_PORT=<ftp-server-port>
FTP_USER=<ftp-username>
FTP_PASSWORD=<ftp-password>
OUTBOUND_DIR=<remote-outbound-dir>
INBOUND_DIR=<remote-inbound-dir>
LOCAL_STORAGE_DIR=<local-storage-dir>
CRA_PUB_CERT_PATH=<public-certificate-path>
CRA_PRIVATE_KEY_PATH=<private-key-path>
- Install dependencies:
npm install
- Run the service:
npm run start:dev
- Access API docs: Visit http://localhost:3000/api/docs for Swagger UI.
POST /api/transfers- Encrypts the uploaded flat file , stores it locally, then uploads the encrypted file to the CRA FTP server.
- Body:
multipart/form-datawithfile,destinationId,fileName
GET /api/transfers/:destinationId/:fileName- This will ensure file is successfully uploaded to CRA or not
GET /api/destinations/:destinationId/remote/inbound/files/:fileName- Downloads the encrypted file from the CRA FTP server, stores the ecrypted file locally, then decrypt & returns the decrypted file to the client.
GET /api/destinations/:destinationId/local/inbound/:fileName- Download a file from local storage.
GET /api/destinations/:destinationId/remote-files- List files available on the remote FTP server.
GET /api/destinations/:destinationId/local-files- List files available in local storage.
GET /api/destinations/:destinationId/health- Check FTP server health status.
src/
app.module.ts
main.ts
configs/
common/
ftp/
controllers/
services/
dto/
interfaces/
Run unit and integration tests:
npm run testThis project is licensed under the MIT License.
See CONTRIBUTING.md for guidelines.
See SECURITY.md for security policy and reporting vulnerabilities.
For questions or support, please open an issue or contact the maintainers.