Skip to content

Commit

Permalink
Merge branch 'prod' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshitShukla-dev authored Jul 15, 2024
2 parents 57e61e8 + 2677966 commit 3a4638d
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 17 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/prod_edventure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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 - edventure

on:
push:
branches:
- prod
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: node-app
path: release.zip

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@v3
with:
name: node-app

- name: Unzip artifact for deployment
run: unzip release.zip

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_88218DBA312445B8A13AEBE0D933F231 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_21F46878DA51410284E00CBFA9599ED6 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_1D65A3A7864F406EB63FC0EE3A38308E }}

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

55 changes: 55 additions & 0 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-23.11"; # or "unstable"

# Use https://search.nixos.org/packages to find packages
packages = [
# pkgs.go
# pkgs.python311
# pkgs.python311Packages.pip
# pkgs.nodejs_20
# pkgs.nodePackages.nodemon
];

# Sets environment variables in the workspace
env = {};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
extensions = [
# "vscodevim.vim"
];

# Enable previews
previews = {
enable = true;
previews = {
# web = {
# # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
# # and show it in IDX's web preview panel
# command = ["npm" "run" "dev"];
# manager = "web";
# env = {
# # Environment variables to set for your server
# PORT = "$PORT";
# };
# };
};
};

# Workspace lifecycle hooks
workspace = {
# Runs when a workspace is first created
onCreate = {
# Example: install JS dependencies from NPM
# npm-install = "npm install";
};
# Runs when the workspace is (re)started
onStart = {
# Example: start a background task to watch and re-build backend code
# watch-backend = "npm run watch-backend";
};
};
};
}
6 changes: 3 additions & 3 deletions Backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ app.use(express.json())
app.use(cookieparser())
app.use("/api/v1",rootRouter)

app.listen(3000,function() {
console.log("Listening on Port: 3000")
})
app.listen(process.env.PORT || 8080, function() {
console.log(`Listening on Port: ${process.env.PORT || 8080}`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ChatComponent implements OnInit {

setInterval(() => {
this.http
.get('http://localhost:3000/api/v1/group/getmsgs', {
.get('http://edventure.azurewebsites.net/api/v1/group/getmsgs', {
params: { loggedInUsername: this.loggedInUsername }
})
.subscribe((response: any) => {
Expand All @@ -42,7 +42,7 @@ export class ChatComponent implements OnInit {
} // create the body of the request

this.http
.post('http://localhost:3000/api/v1/group/msgGroup', body)
.post('http://edventure.azurewebsites.net/api/v1/group/msgGroup', body)
.subscribe((response: any) => {})

this.content = '' // clear the input field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class DashboardNavComponent {
constructor(public http: HttpClient, private router: Router) { }

logout() {
this.http.get("http://localhost:3000/api/v1/user/logout",{withCredentials:true}).subscribe(
this.http.get("http://edventure.azurewebsites.net/api/v1/user/logout",{withCredentials:true}).subscribe(
() => {
// Success: delete all cookies for domain 'localhost' and path '/'
// Assuming you're using ngx-cookie-service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class HomeComponent implements OnInit {
}

checkCookie(): void {
this.http.post("http://localhost:3000/api/v1/user/checkCookie", {}, {withCredentials: true}).subscribe(
this.http.post("http://edventure.azurewebsites.net/api/v1/user/checkCookie", {}, {withCredentials: true}).subscribe(
(response: any) => {
if(response.msg == "Log in Success")
this.router.navigate(['/dashboard'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class LoginComponent {
this.body.username = form.value.email;
this.body.password = form.value.password;
this.http
.post('http://localhost:3000/api/v1/user/signin', this.body, {withCredentials: true})
.post('http://edventure.azurewebsites.net/api/v1/user/signin', this.body, {withCredentials: true})
.subscribe((response: any) => {
this.state = response.msg;
if(this.state == "Log In Success"){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class SignupComponent {
this.userData.email = email;
this.setotp.email = email;
this.http
.post('http://localhost:3000/api/v1/user/getotp', body)
.post('http://edventure.azurewebsites.net/api/v1/user/getotp', body)
.subscribe((response: any) => {
this.state = response.msg;
});
Expand All @@ -86,7 +86,7 @@ export class SignupComponent {
this.setotp.method = 'signup';
// Send a request to the server to verify the OTP
this.http
.post('http://localhost:3000/api/v1/user/verifyotp', this.setotp)
.post('http://edventure.azurewebsites.net/api/v1/user/verifyotp', this.setotp)
.subscribe((response: any) => {
console.log(response);
this.state = response.msg;
Expand All @@ -101,7 +101,7 @@ export class SignupComponent {
if (form.valid) {
this.userData.educational_institute = form.value.college;
this.http
.post('http://localhost:3000/api/v1/user/signup', this.userData)
.post('http://edventure.azurewebsites.net/api/v1/user/signup', this.userData)
.subscribe((response: any) => {
this.state = response.msg;
console.log(response)
Expand Down
11 changes: 8 additions & 3 deletions package-lock.json

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

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "edventure",
"scripts": {
"Frontend": "cd EdVenture-FrontEnd && ng serve",
"Backend": "cd Backend && npx tsc && cd dist && node index.js"
"Backend": "cd Backend && npx tsc && cd dist && node index.js",
"build": "cd Backend && npx tsc"
},
"dependencies": {
"@types/argon2": "^0.15.0",
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
Expand All @@ -15,15 +15,18 @@
"@types/otp-generator": "^4.0.2",
"@types/ws": "^8.5.10",
"argon2": "^0.40.1",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"jsonwebtoken": "^9.0.2",
"nodemailer": "^6.9.13",
"otp-generator": "^4.0.1",
"typescript": "^5.5.3",
"ws": "^8.16.0",
"zod": "^3.22.4",
"typescript": "^5.4.5"
"devDependencies": {
"@types/cookie-parser": "^1.4.7",
"cookie-parser": "^1.4.6"
}
}

0 comments on commit 3a4638d

Please sign in to comment.