GithubHelp home page GithubHelp logo

raptisj / artiz-mono-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 44 KB

A NodeJS, MongoDB API that lists artists and their songs. Authenticated users can perform actions such as liking a song, following an artist and creating playlists.

Dockerfile 0.46% TypeScript 99.54%

artiz-mono-api's Introduction

๐ŸŽน Artiz MoNo API ๐Ÿฅ

An API that lists artists and their songs. Authenticated users can perform actions such as liking a song, following an artist and creating playlists.

Technologies used: MongoDB, NodeJS, Mongoose and Docker.

Features

  • custom user auth
  • artists list
  • single artist
  • follow artist
  • song list per artists
  • liked songs
  • create playlists
  • user profile
  • pagination

Usage and Info


git clone [email protected]:raptisj/artiz-mono-api.git
cd ./artiz-mono-api

To run:


docker-compose up โ€”-build

To connect to a MongoDB shell:


docker exec -it mongodb /bin/bash
mongosh

Info: MongoDB shell commands cheatsheet

Info: Get started with MongoDB and Mongoose

Generate data

I used ChatGPT to generate the data. To do so youself you can insert the prompts from the data/prompts/index.md file. Replace curly braces with your intended value

Import data

In the data folder there are two JSON files.

First, we need to copy each file to the container. Second, we need to run mongoimport to populate the database.

Note: Mongo usually generates an _id of type ObjectId for us. Here we add it explicitly in a format that mongoimport can understand in order to generate an _id in the correct format.


docker cp ./data/artists.json mongodb:/artists.json \
&& docker exec mongodb mongoimport --db mono --collection artists --drop --file /artists.json --jsonArray --mode upsert \
&& docker cp ./data/songs.json mongodb:/songs.json \
&& docker exec mongodb mongoimport --db mono --collection songs --drop --file /songs.json --jsonArray --mode upsert

To try out the API you can use Postman. Register a user and copy the access token in the response to your clipboard. Paste it in the Authorization > Bearer Token section in the token field.

Screen Shot 2023-11-26 at 5 44 17 PM

Structure of data

Artist

[
  {
    "_id": "5fc612c4397f9b74b2e8c266",
    "name": "Pat Metheny",
    "birth_year": 1954,
    "instrument": "Guitar",
    "genre": "Jazz",
    "bio": "Pat Metheny is an American jazz guitarist known for his innovative and diverse musical style. He has won numerous awards, including 20 Grammy Awards across various categories. Metheny's work spans jazz fusion, contemporary jazz, and beyond, showcasing his virtuosity and creativity.",
    "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Pat_Metheny.jpg/500px-Pat_Metheny.jpg"
  }
]

Song

[
  {
    "_id": "5fc6140f397f9b74b2e8c268",
    "artist_id": "5fc612c4397f9b74b2e8c266",
    "title": "Last Train Home",
    "album": "Still Life (Talking)",
    "year": 1987,
    "duration": "5:42",
    "genre": "Jazz Fusion",
    "added_to_playlist_dates": "2023-11-24T18:38:34.064Z" // only visible within a playlist
  }
]

User

[
  {
    "_id": "09d6140f397f5b74b4e8c244",
    "username": "doe",
    "email": "[email protected]",
    "liked_songs": ["1", "2", "3"],
    "following": ["11", "22", "33"]
  }
]

Playlist

[
  {
    "_id": "09d6140f397f5b74b4e8c244",
    "user_id": "9d6147f58c244b700f394b4e",
    "song_ids": ["1", "2", "3"],
    "title": "Jazz hits",
    "description": "A smooth collection",
    "song_count": 4,
    "total_track_duration_in_seconds": 1123123,
    "total_track_duration": "1h 20m" // from a virtual
  }
]

Author

John Raptis

artiz-mono-api's People

Contributors

raptisj 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.