Skip to content

Commit

Permalink
LL-250 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikajledesma authored Jun 20, 2024
2 parents 8014277 + 48101c4 commit 37f19ff
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
61 changes: 34 additions & 27 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
version: "3.8"

services:
account:
build: "src/account/"
command: "npm run account"
ports:
- "5000:5000"
env_file: "src/account/.env"
dns:
- "8.8.8.8"
routes:
build: "src/routes/"
command: "npx ts-node github.ts"
ports:
- "4000:4000"
- "8080:8080"
env_file: "src/routes/.env"
# client:
# build: "client/"
# command: "npm start"
# ports:
# - "3000:3000"
# env_file: ".env"
# # Requires server services to run before running client servers
# depends_on:
# - "server"

version: "3.8"

services:
# account:
# build: "src/account/"
# command: "npm run account"
# ports:
# - "5000:5000"
# env_file: "src/account/.env"
# dns:
# - "8.8.8.8"
models:
build: "src/models/"
command: "echo Models Container Working"
routes:
build: "src/routes/"
command: "npx ts-node github.ts"
ports:
- "4000:4000"
- "8080:8080"
env_file: "src/routes/.env"
depends_on:
- "models"
client:
build: "client/"
command: "npm start"
ports:
- "3000:3000"
env_file: "src/routes/.env"
# Requires server services to run before running client servers
depends_on:
# - "account"
- "routes"
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"@types/mongoose": "^5.11.97",
"@types/node": "^20.10.0"
}
}
}
9 changes: 9 additions & 0 deletions src/models/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:latest

WORKDIR /models

# Copies files from the models directory
COPY ["DeviceSchema.ts", "/models"]
COPY ["UserSchema.ts", "/models"]

RUN ["/bin/bash", "-c", "echo Models Image Built!"]
3 changes: 1 addition & 2 deletions src/routes/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ router.get("/github/callback", async (req: any, res: any) => {

const user = await getUser({ code });

console.log(user);
res.redirect("http://localhost:3000")
res.send(user);
})

export {};
54 changes: 27 additions & 27 deletions src/routes/routes.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
const express = require("express");
const User = require("../models/UserSchema")
// const User = require("../models/UserSchema");

export const router = express.Router()

// Register method
router.post('/register', (req: any, res: any) => {
const user = new User({
email:req.body.email,
name:req.body.name
})
user.save(function (err: any, res: any) {
if (err) {
console.log(err)
}
else {
console.log(res)
}
})
})
// router.post('/register', (req: any, res: any) => {
// const user = new User({
// email:req.body.email,
// name:req.body.name
// })
// user.save(function (err: any, res: any) {
// if (err) {
// console.log(err)
// }
// else {
// console.log(res)
// }
// })
// })

// Get all method

// Get one method
router.post('/account', async (req: any, res: any) => {
User.find({}, function(err: any, users: any) {
let loginIn = false
// router.post('/account', async (req: any, res: any) => {
// User.find({}, function(err: any, users: any) {
// let loginIn = false

// Check if one of the users in the db is already present
// If so set that equal to flag, if not then indicate the user isn't registered
users.forEach(function(user: any) {
if (req.body.email === user.email)
loginIn = true
});
// // Check if one of the users in the db is already present
// // If so set that equal to flag, if not then indicate the user isn't registered
// users.forEach(function(user: any) {
// if (req.body.email === user.email)
// loginIn = true
// });

res.send({'success' : loginIn});
});
})
// res.send({'success' : loginIn});
// });
// })

// Update one

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10591,4 +10591,4 @@ [email protected]:
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

0 comments on commit 37f19ff

Please sign in to comment.