Home

Awesome

MindCast-Server Build Status MIT license

This is the back-end of the MindCast App.

It's a RESTful API built with NodeJS + Express + MongoDB that receive all the data related with authors and podcats and record/provide to the client all this data through a REST API.

The main purpose of this API is stream audio files, podcasts were selected by me just to give some context to the app. So, you can reuse all this code to upload/stream a audio (just tested with .mp3) file and use inside your own context (music app, your own podcasts or whatever!).

About this Project

This project is part of my personal portfolio, so, I'll be happy if you could provide me any feedback about the project, code, structure or anything that you can report that could make me a better developer!

Email-me: stenio.wagner1@gmail.com

Connect with me at LinkedIn

Also, you can use this Project as you wish, be for study, be for make improvements or earn money with it!

It's free!

Getting Started

Prerequisites

To run this project in the development mode, you'll need to have a basic environment with NodeJS 8+ installed. To use the database, you'll need to have MongoDB installed and running on your machine at the default port (27017).

Installing

Cloning the Repository

$ git clone https://github.com/steniowagner/mindcast-server

$ cd mindcast-server

Installing dependencies

$ yarn

or

$ npm install

Running the Development environment

Now, you'll need to change to development branch:

$ git checkout development

With all dependencies installed, the Database running and the environment properly configured, you can now run the server:

$ yarn dev

or

$ npm run dev

Running the Tests

$ yarn test

or

$ npm run test

Running the Tests + Coverage

$ yarn test:coverage

or

$ npm run test:coverage

Routes

The base URL is: http://localhost:3001/mind-cast/api/v1/

Test Route

http://localhost:3001/mind-cast/api/v1/

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/GET--Code: 200 - OK<br />Content: { message: "UHUL! The API is UP && RUNNING!" }Code: 500 - INTERNAL SERVER ERROR <br />Content: { error: <A Message with a description of the Error> }

Home

EX:

http://localhost:3001/mind-cast/api/v1/home?categories=all

http://localhost:3001/mind-cast/api/v1/home?categories=science&categories=history

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/homeGET-categories: CategoryCode: 200 - OK<br />Content: <br />{<br /> hottestPodcasts: [Podcast],<br />newReleases: [Podcast],<br />trendingAuthors: [Author]<br />}<br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }

Category

EX:

http://localhost:3001/mind-cast/api/v1/categories/science

http://localhost:3001/mind-cast/api/v1/categories/philosofy

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/categories/:categoryGETcategory: Category-Code: 200 - OK<br />Content: <br />{<br /> featured: [Podcast],<br />trending: [Podcast],<br />authors: [Author]<br />}<br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }

Authors

http://localhost:3001/mind-cast/api/v1/authors/:id/podcasts

For this request, you'll need to send the .mp3 file and all the Podcast data. If you don't know how to send a file using a http client tool, here's an example of how to do it with Postman.

Preview-Screens

Don't forget to send the fields of the Podcast that are described on the image!

<br />
ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/authors/:id/podcastsPOSTid-Code: 201 - CREATED <br />Content: { <br /> podcast: Podcast<br /> }Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/authors

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/authorsPOSTAuthor-Code: 201 - CREATED <br />Content: { id: <ID of the Author Created> }Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/authors

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/authorsGET--Code: 200 - OK<br />Content: <br />{<br /> authors: [Author],<br />}<br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/authors/:id

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/authors/:idGETid-Code: 200 - OK<br />Content: <br />{<br /> author: Author,<br />}Code: 404 - NOT FOUND<br />Content: { message: "Author not found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/authors/:id

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/authors/:idPATCHRequired:<br />Fields that will be updated<br /><br />idCode: 200 - OK<br />Content: <br />{<br /> author: Author<br />}Code: 404 - NOT FOUND<br />Content: { message: "Restaurant Not Found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/authors/:id

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/author/:idDELETEid-Code: 204 - NO CONTENT<br />Code: 404 - NOT FOUND<br />Content: { message: "Author not found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

EX:

http://localhost:3001/mind-cast/api/v1/authors/filter?name=stark

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/authors/:idGETid-Code: 200 - OK<br />Content: <br />{<br /> author: Author,<br />}Code: 404 - NOT FOUND<br />Content: { message: "Author not found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

Podcasts

http://localhost:3001/mind-cast/api/v1/podcasts

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/podcastsGET--Code: 200 - OK<br />Content: <br />{<br /> podcasts: [Podcast],<br />}<br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/podcasts/:id

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/podcasts/:idGETid-Code: 200 - OK<br />Content: <br />{<br /> podcast: Podcast,<br />}Code: 404 - NOT FOUND<br />Content: { message: "Podcast not Found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/podcasts/:id/listen

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/podcasts/:id/listenGETid-Code: 206 - Partial Content<br />Content: <br />Stream of a podcast audio fileCode: 404 - NOT FOUND<br />Content: { message: "Podcast not Found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

http://localhost:3001/mind-cast/api/v1/podcasts/:id/download

ENDPOINTMethodParamsURL ParamsSuccess ResponseError Response
/podcasts/:id/downloadGETid-Code: 200 - OK<br />Content: <br />Stream of a podcast audio fileCode: 404 - NOT FOUND<br />Content: { message: "Podcast not Found." }<br /><br />or<br /><br />Code: 500 - INTERNAL SERVER ERROR<br />Content: { error: <A Message with a description of the Error> }
<br />

Models

Category

 {
  "enum": "science | technology | philosofy | business | pop-culture | history",
 }

Author

podcasts: Author's podcasts.

categories: Categories of the Author.

name: Author's name.

profileImageURL: An URL of an image to represent the Author (you can use some image with more than 600 x 400)

thumbnailProfileImageURL: The same image of imageURL, but with a smaller scale (less than (90 x 90))

podcasts: This field isn't required for any request from the user, it will always be sent by the server.

about: A description of the Author.

{
  "podcasts": {
    "type": "[MONGOOSE.SCHEMA.TYPES.OBJECT_ID]",
    "required": false,
    "default": [],
  },
  "categories": {
    "type": "[Category]",
    "required": true,
  },
  "name": {
    "type": "String",
    "required": true,
  },
  "profileImageURL": {
    "type": "String",
    "required": true,
  },
  "thumbnailProfileImageURL": {
    "type": "String",
    "required": true,
  },
  "about": {
    "type": "String",
    "required": true,
  },
}

Podcast

author: ID of the author.

"title": Title of the podcast.

"description": Description of the podcast.

imageURL: An image to represent the podcast (you can use some image with more than 600 x 400)

thumbnailImageURL: The same image of imageURL, but with a smaller scale (less than (90 x 90).

category: Category of the podcast.

stars: Stars of the podcast.

duration, durationInSeconds and fileName: These fields are created and sent by the server after to analyze and parse the uploaded audio file, and aren't required for any request.

{
   "author": {
    "type": "MONGOOSE.SCHEMA.TYPES.OBJECT_ID",
    "required": false,
  },
  "title": {
    "type": "String",
    "required": true,
  },
  "description": {
    "type": "String",
    "required": true,
  },
  "imageURL": {
    "type": "String",
    "required": true,
  },
  "thumbnailImageURL": {
    "type": "String",
    "required": true,
  },
  "category": {
    "type": "Category",
    "required": true,
  },
  "stars": {
    "type": "Number",
    "required": true,
  },
  "duration":  {
   "type":  "String",
  },
  "durationInSeconds":  {
   "type":  "Number",
  },
  "fileName":  {
   "type":  "String",
  }
}

Built With

Support tools

Contributing

You can send how many PR's do you want, I'll be glad to analyse and accept them! And if you have any question about the project...

Email-me: stenio.wagner1@gmail.com

Connect with me at LinkedIn

Thank you!

License

This project is licensed under the MIT License - see the LICENSE.md file for details.