Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 12, 14, 16
"args": {
"VARIANT": "14"
"VARIANT": "16"
}
},

Expand Down
6 changes: 6 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"targets": {},
"projects": {
"default": "spotify-get-rid-of-shit"
}
}
15 changes: 10 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ jobs:

- name: 'Install Dependencies'
run: npm ci

- uses: mansagroup/nrwl-nx-action@v2
name: 'Build apps'
with:
targets: build
affected: 'true' # Defaults to true, therefore optional

- name: Build apps
run: npm run nx affected:build

- name: 'Build docker images'
run: npm run nx affected -- --target=docker --push --all
- uses: mansagroup/nrwl-nx-action@v2
name: 'Build docker images'
with:
targets: build
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ testem.log
Thumbs.db

**/.env

.runtimeconfig.json

**/*-debug.log
.firebase
*.log
**/firebase-admin-key.json
10 changes: 10 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ RUN wget https://github.com/gruntwork-io/cloud-nuke/releases/download/${CLOUD_NU
### https://github.com/jckuester/awsls#installation
RUN brew install jckuester/tap/awsls

RUN npm i -g firebase-tools

RUN curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-324.0.0-linux-x86_64.tar.gz &&\
tar -xvzf google-cloud-sdk-324.0.0-linux-x86_64.tar.gz &&\
cd ./google-cloud-sdk/ && ./install.sh -q --quiet

ENV PATH=~/google-cloud-sdk/bin:$PATH

# please take a closer look at this doc https://firebase.google.com/docs/admin/setup?authuser=0 on how to gen app credentials
ENV GOOGLE_APPLICATION_CREDENTIALS=./apps/spotify-auth-firebase-functions/firebase-admin-key.json
32 changes: 30 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@ image:
# List the ports you want to expose and what to do when they are served. See https://www.gitpod.io/docs/config-ports/
ports:
- port: 3000
onOpen: open-preview
onOpen: ignore
visibility: private
- port: 4000
onOpen: open-browser
visibility: private
- port: 5001
onOpen: ignore
- port: 9000
onOpen: ignore
- port: 9099
onOpen: ignore
- port: 5000
onOpen: ignore
- port: 8085
onOpen: ignore
- port: 5001
onOpen: ignore


# List the start up tasks. You can start them in parallel in multiple terminals. See https://www.gitpod.io/docs/config-start-tasks/
tasks:
Expand All @@ -15,7 +31,19 @@ tasks:
cp apps/app/src/.env.example apps/app/.env
npm install

command: node tools/configure-aws-profile.js && npm run dev
npm --version
node --version
npx firebase --version

npx firebase --token=$FIREBASE_TOKEN projects:list

before: npm install

- name: nx run spotify-auth-firebase-functions:emulate
command: npx nx run spotify-auth-firebase-functions:emulate

- name: nx run spotify-auth-firebase-functions:build
command: nx run spotify-auth-firebase-functions:build --watch

vscode:
extensions:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"users",
"nx",
"devx",
"spotify-passport-auth-express"
"spotify-passport-auth-express",
"spotify-auth"
]
}
18 changes: 18 additions & 0 deletions apps/spotify-auth-firebase-functions/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@baseUrl={{$dotenv BASE_URL }}
@token={{$dotenv token}}

GET {{baseUrl}}/spotifyAuth

### Remove track from own playlist
### https://open.spotify.com/playlist/0mHp4YGQafLceibtfhe1FB

GET {{baseUrl}}/cloneOrEditPlaylistHttp?playlist_id=0mHp4YGQafLceibtfhe1FB
Authorization: Bearer {{token}}

### Clone the original playlist due to lack of permissions to edit playlist tracks

# https://open.spotify.com/playlist/37i9dQZF1DX5ECfKO3L7Vd
GET {{baseUrl}}/cloneOrEditPlaylistHttp?playlist_id=37i9dQZF1DX5ECfKO3L7Vd
Authorization: Bearer {{token}}

###
GET {{baseUrl}}/convertCustomTokenToIdToken
Authorization: Bearer {{$dotenv customUserToken}}
7 changes: 7 additions & 0 deletions apps/spotify-auth-firebase-functions/database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": false,
".write": false
}
}
3 changes: 3 additions & 0 deletions apps/spotify-auth-firebase-functions/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"indexes": []
}
12 changes: 12 additions & 0 deletions apps/spotify-auth-firebase-functions/firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
rules_version = '2';
// These default Firestore rules were generated by Nx-Firebase plugin
// Change them to suit your own requirements.

// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
22 changes: 22 additions & 0 deletions apps/spotify-auth-firebase-functions/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { resolve } = require('path')

// https://github.com/firebase/firebase-functions/blob/v3.16.0/src/config.ts#L99
process.env.CLOUD_RUNTIME_CONFIG = resolve(__dirname, '.runtimeconfig.json')
process.env.FIRESTORE_EMULATOR_HOST = 'localhost:8080'
process.env.FIREBASE_AUTH_EMULATOR_HOST = 'localhost:9099'

module.exports = {
displayName: 'spotify-auth-firebase-functions',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/spotify-auth-firebase-functions',
testEnvironment: 'node',
}
20 changes: 20 additions & 0 deletions apps/spotify-auth-firebase-functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@lazyorange/spotify-auth-firebase-functions",
"description": "Firebase Functions package, auto generated by @simondotm/nx-firebase",
"scripts": {
"lint": "cd ../../ && nx lint spotify-auth-firebase-functions",
"build": "cd ../../ && nx build spotify-auth-firebase-functions --with-deps",
"serve": "npm run build && firebase emulators:start --only functions --config ../../firebase.spotify-auth-firebase-functions.json",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions --config ../../firebase.spotify-auth-firebase-functions.json",
"logs": "firebase functions:log"
},
"engines": {
"node": "16"
},
"main": "main.js",
"dependencies": {},
"devDependencies": {},
"private": true
}
81 changes: 81 additions & 0 deletions apps/spotify-auth-firebase-functions/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"root": "apps/spotify-auth-firebase-functions",
"sourceRoot": "apps/spotify-auth-firebase-functions/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/node:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/spotify-auth-firebase-functions",
"main": "apps/spotify-auth-firebase-functions/src/index.ts",
"tsConfig": "apps/spotify-auth-firebase-functions/tsconfig.app.json",
"packageJson": "apps/spotify-auth-firebase-functions/package.json",
"generatePackageJson": true
}
},
"build-by-nx-firebase": {
"executor": "@simondotm/nx-firebase:build",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/spotify-auth-firebase-functions",
"main": "apps/spotify-auth-firebase-functions/src/index.ts",
"tsConfig": "apps/spotify-auth-firebase-functions/tsconfig.app.json",
"packageJson": "apps/spotify-auth-firebase-functions/package.json",
"assets": [
"apps/spotify-auth-firebase-functions/*.md",
"apps/spotify-auth-firebase-functions/.runtimeconfig.json"
]
}
},
"deploy": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "firebase deploy --config firebase.spotify-auth-firebase-functions.json"
}
},
"getconfig": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "firebase functions:config:get --config firebase.spotify-auth-firebase-functions.json > apps/spotify-auth-firebase-functions/.runtimeconfig.json"
}
},
"emulate": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "firebase emulators:start --config firebase.spotify-auth-firebase-functions.json --inspect-functions --only auth,functions,firestore,database"
}
},
"serve": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "nx run spotify-auth-firebase-functions:build --with-deps && nx run spotify-auth-firebase-functions:build --watch"
},
{
"command": "nx run spotify-auth-firebase-functions:emulate"
}
],
"parallel": true
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/spotify-auth-firebase-functions/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/apps/spotify-auth-firebase-functions"],
"options": {
"jestConfig": "apps/spotify-auth-firebase-functions/jest.config.js",
"passWithNoTests": true,
"testEnvironment": "node"
}
}
},
"tags": []
}
Loading