-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mirko
committed
Aug 5, 2022
0 parents
commit ec6eceb
Showing
130 changed files
with
15,324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
info: | ||
@echo "make option are:" | ||
@echo " - run-frontend " | ||
@echo " - run-backend " | ||
@echo " - run-db " | ||
@echo " - build-frontend " | ||
|
||
|
||
|
||
init-backend: | ||
cd noSpotify-Backend && npm i && npm run start && cd .. | ||
|
||
init-frontend: | ||
cd noSpotify-Frontend && npm i --force && ng serve && cd .. | ||
|
||
clear-backend: | ||
cd noSpotify-Backend && rm -R node_modules && npm i && npm run start && cd .. | ||
|
||
clear-frontend: | ||
cd noSpotify-Frontend && rm -R node_modules && npm i --force && ng serve && cd .. | ||
|
||
build-frontend: | ||
cd noSpotify-Frontend && ng build --aot --prod --output-hashing none && cd .. | ||
|
||
run-frontend: | ||
cd noSpotify-Frontend && ng serve && cd .. | ||
|
||
run-backend: | ||
cd noSpotify-Backend && npm run start && cd .. | ||
|
||
run-db: | ||
docker-compose up -d | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# NoSpotify | ||
# NoSpotify | ||
# NoSpotify | ||
# NoSpotify |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
mongo-container: | ||
image: mongo:3.4.2 | ||
environment: | ||
# provide your credentials here | ||
- MONGO_INITDB_ROOT_USERNAME=root | ||
- MONGO_INITDB_ROOT_PASSWORD=rootPassword | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
# if you wish to setup additional user accounts specific per DB or with different roles you can use following entry point | ||
- "$PWD/mongo-entrypoint/:/docker-entrypoint-initdb.d/" | ||
# no --auth is needed here as presence of username and password add this option automatically | ||
command: mongod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
typings | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const config = require('config.json'); | ||
const mongoose = require('mongoose'); | ||
const connectionOptions = { useCreateIndex: true, useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false }; | ||
mongoose.connect(process.env.MONGODB_URI || config.connectionString, connectionOptions); | ||
mongoose.Promise = global.Promise; | ||
|
||
module.exports = { | ||
User: require('../users/user.model'), | ||
Playlist: require('../users/playlist.model') | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = errorHandler; | ||
|
||
function errorHandler(err, req, res, next) { | ||
if (typeof (err) === 'string') { | ||
// custom application error | ||
return res.status(400).json({ message: err }); | ||
} | ||
|
||
if (err.name === 'ValidationError') { | ||
// mongoose validation error | ||
return res.status(400).json({ message: err.message }); | ||
} | ||
|
||
if (err.name === 'UnauthorizedError') { | ||
// jwt authentication error | ||
return res.status(401).json({ message: 'Invalid Token' }); | ||
} | ||
|
||
// default to 500 server error | ||
return res.status(500).json({ message: err.message }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const expressJwt = require('express-jwt'); | ||
const config = require('config.json'); | ||
const userService = require('../users/user.service'); | ||
|
||
module.exports = jwt; | ||
|
||
function jwt() { | ||
const secret = config.secret; | ||
let ok = expressJwt({ secret, algorithms: ['HS256'], isRevoked }).unless({ | ||
path: [ | ||
// public routes that don't require authentication | ||
'/users/authenticate', | ||
'/users/register', | ||
'/users/getMp3', | ||
'/youtube/*', | ||
{ url: /^\/youtube\/.*/, methods: ['GET'] } | ||
] | ||
}); | ||
|
||
return ok; | ||
} | ||
|
||
async function isRevoked(req, payload, done) { | ||
const user = await userService.getById(payload.sub); | ||
|
||
// revoke token if user no longer exists | ||
if (!user) { | ||
return done(null, true); | ||
} | ||
|
||
done(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"connectionString": "mongodb://root:rootPassword@localhost:27017/?authSource=admin", | ||
"secret": "$3cr3tSeRver!", | ||
"spotifyEmail":"", | ||
"spotifyPassword":"", | ||
"spotifyAppId":"" | ||
} |
Oops, something went wrong.