Giter Site home page Giter Site logo

oguzhan18 / station-service Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 2.17 MB

Each station can upload and queue music files, stream them to clients, and handle multiple clients simultaneously. This service is particularly useful for creating online radio stations where users can upload music and stream it live.

JavaScript 5.06% HTML 14.57% TypeScript 80.37%
api music nestjs nestjs-api nestjs-backend station station-stream stream swagger

station-service's Introduction

Station Service Project

Overview

The Station Service project is a NestJS application designed to manage and stream music files for virtual radio stations. Each station can upload and queue music files, stream them to clients, and handle multiple clients simultaneously. This service is particularly useful for creating online radio stations where users can upload music and stream it live.

Features

  • Create Stations: Dynamically create new radio stations with unique IDs.
  • Upload Music: Upload music files to specific stations.
  • Stream Music: Stream music files in a loop to connected clients.
  • Station Status: Get the current playback status of a station, including the current file, file size, and playback position.

Technologies Used

  • NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
  • TypeScript: A strongly typed programming language that builds on JavaScript.
  • Express: A minimal and flexible Node.js web application framework. Jest: A delightful JavaScript testing framework with a focus on simplicity.

Getting Started

Prerequisites

Ensure you have the following installed:

  • Node.js (>= 14.x)
  • npm (>= 6.x)

Installation

  1. Clone the repository:
git clone https://github.com/oguzhan18/station-service

cd station-service
  1. Install dependencies:
npm install

Running the Application

To start the application in development mode:

npm run start:dev

The application will be accessible at http://localhost:3000.

API Endpoints

Create a Station

  • Endpoint: POST /music/create
  • Description: Creates a new radio station and returns the station ID.
  • Response:
{
  "id": "station-id"
}

Upload Music

  • Endpoint: POST /music/:stationId/upload
  • Description: Uploads a music file to the specified station.
  • Parameters:
    1. stationId (path): The ID of the station.
  • Body: Multipart/form-data with the file to be uploaded.
  • Response:
{
  "filePath": "path-to-uploaded-file"
}

Stream Music

  • Endpoint: GET /music/:stationId/stream
  • Description: Streams the current music file for the specified station.
  • Parameters:
    1. stationId (path): The ID of the station.
  • Response: Audio stream.

Get Station Status

  • Endpoint: GET /music/:stationId/status
  • Description: Gets the current status of the station.
  • Parameters:
    1. stationId (path): The ID of the station.
  • Response:
{
  "currentFile": "current-playing-file",
  "currentFileSize": 123456,
  "currentFilePosition": 60.5
}

Testing

Unit tests are written using Jest. To run the tests:

npm run test

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature-name.
  3. Make your changes and commit them: git commit -m 'Add some feature'.
  4. Push to the branch: git push origin feature/your-feature-name.
  5. Submit a pull request.

station-service's People

Contributors

oguzhan18 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.