Skip to content

Commit

Permalink
backend commit
Browse files Browse the repository at this point in the history
  • Loading branch information
christinadechalk committed Nov 19, 2024
2 parents 5dfe095 + 5296b58 commit 8e10fa4
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 23 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/backend_focusfruit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - focusfruit

on:
push:
branches:
- backend
workflow_dispatch:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: .

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_290EF528711248B6AB538DE20E380C7C }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_EA503942294841D9B9320C5CE49A36E3 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_377FE0A7E8154614A9075E7EFFF0FB94 }}

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'focusfruit'
slot-name: 'Production'
package: .

17 changes: 17 additions & 0 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: CI Testing

on:
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm ci
- run: npm run lint
- run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
.env

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ This is our csc-307 project and we are hoping to make a Pomodoro website. We are
- Madison Lopez
- Ivy Van Zant
- Christina Dechalk

## Contributing

**Atlas Format**
.env :

MONGODB_URI=mongodb+srv://username:password@host.net/?
w=majority
appName= ...
retryWrites=true
36 changes: 28 additions & 8 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
],
"main": "index.js",
"scripts": {
"lint:backend": "npm run -w packages/backend lint",
"lint:frontend": "npm run -w packages/frontend lint",
"test:backend": "npm run -w packages/backend test",
"test:frontend": "npm run -w packages/frontend test",
"dev": "npm run -w packages/frontend dev",
"lint": "eslint .",
"format": "prettier --write .",
"dev": "npm run --workspace=packages/frontend dev"
"build:frontend": "npm run -w packages/frontend build"
},
"keywords": [],
"author": "Thomas, Ivy, Madison, Ivy",
"author": "Thomas, Ivy, Madison, Christina",
"license": "ISC",
"devDependencies": {
"eslint": "^8.57.1",
Expand All @@ -21,6 +26,7 @@
"prettier": "^2.0.0"
},
"dependencies": {
"dotenv": "^16.4.5",
"mongoose": "^8.8.0",
"validator": "^13.12.0"
}
Expand Down
7 changes: 5 additions & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "module",
"main": "backend.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "jest",
"lint": "eslint . && prettier --check .",
"dev": "npx nodemon backend.js"
},
"author": "",
Expand All @@ -15,6 +16,8 @@
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.1"
"dotenv": "^16.4.5",
"express": "^4.21.1",
"validator": "^13.12.0"
}
}
4 changes: 2 additions & 2 deletions packages/backend/task_services.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import mongoose from "mongoose";
import taskModel from "./task_schema"
import userModel from "./user_schema"

mongoose.set("debug", true);

Expand All @@ -9,7 +9,7 @@ mongoose.connect("mongodb://localhost:27017/users", {
useUnifiedTopology: true,
}).catch((error) => console.log(error));

function getTask(user) {
function getTask(userId, ) {
let promise;
if (task === undefined) {
promise = userModel.find();
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/user_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function getUsers(username) {
promise = userModel.find();
} else if (username) {
promise = findUserByUsername(username);
return promise;
}
return promise;
}

function findUserByUsername(username) {
Expand Down

0 comments on commit 8e10fa4

Please sign in to comment.