A Playlist API that allows for the owner to create a Database of music collections. Users are able to create an account for themselves. After creating an account, users will then be able to create their own Playlist and then add songs from the database collection.
The Playlist API protects users' password via hashing and set requirements of unique emails and usernames when registering and logging in.
Database: Mongo
Tools: Postman, Heroku
Running this project requires the addition to these environments on your .env file:
- MONGODB_URI
- JWT_SECRET
npm init -y
npm i:
- express
- ejs
- mongoose
- dotenv
- expressvalidator
- morgan
- helmet
- bcrypt
- jsonwebtoken
server -app.get('/) returns message ""Welcome to 'My Songs Crate' where you create your own collection of playlists!!!"
- Router.post: Creates/Registers a new user via AuthSchema; password is hashed
- userRouter.post: User logs in with username and password. Token is sent for further access
- userRouter.get: the endpoint; finds all of the users. User protected with tokens
- /library - creates a new library with a unique id
- /addSong/id - adds a song to the library database
- .get /library - gets/calls the library database with songs listed within an array
- user/playlist - creates a new playlist with name of playlist created by the user
- user/playlist/addSong/id - adds a song to the playlist via id of playlist created
- .get /playlist/id - gets the playlist via id
- username: type: String, required: true,
- email: type: String, required: true,
- birthday: type: Data, required: true,
- age: type: Number, required: true,
- password: type: String, required: true,
- createdat: type: Data, Default
songs:
- songTitle: type: String, required: true,
- artist: type: Sring, required: true,
- year: type: Number, required: true,
- genre: type: String, required: true,
- duration: type: Number, required: false,
- fileType: type: String, required: true
PlayList Name: songs:
- songTitle: type: String, required: true,
- artist: type: Sring, required: true,
- year: type: Number, required: true,
- genre: type: String, required: true,
- duration: type: Number, required: false,
- fileType: type: String, required: true,
- private: type: Boolean, required: false,
- createdat: type: Data, Default
jwtverify: gets token from Header in Postman and matches token sent.
authrouter: uses login fuction to verify user is logged in order to post/create playlist. If password/username do not match, a 400 error will be sent.
- More Routes
- Swagger