Skip to content

Commit

Permalink
Merge pull request #46 from CMU-17-356/front-back-connection
Browse files Browse the repository at this point in the history
Link frontend + backend
  • Loading branch information
bluo999 authored Mar 19, 2022
2 parents e1cb976 + 1e668ed commit 2298fce
Show file tree
Hide file tree
Showing 29 changed files with 1,074 additions and 20,785 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,5 @@ dist
backend/src/**/*.js
backend/scripts/**/*.js
backend/test/**/*.js
backend/config.json

2 changes: 1 addition & 1 deletion backend/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"port": 3000,
"db": "mongodb://127.0.0.1/db"
"db": "mongodb://127.0.0.1/dronuts"
}
73 changes: 42 additions & 31 deletions backend/package-lock.json

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

7 changes: 4 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"homepage": "https://github.com/CMU-17-356/dronuts2022-group-5#readme",
"dependencies": {
"@types/cors": "^2.8.12",
"body-parser": "^1.19.2",
"cors": "^2.8.5",
"express": "^4.17.3",
Expand All @@ -31,11 +32,11 @@
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.19",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"eslint": "^8.9.0",
"eslint": "^8.10.0",
"eslint-config-google": "^0.14.0",
"jest": "^27.5.1",
"mongodb-memory-server": "^8.4.0",
Expand Down
72 changes: 71 additions & 1 deletion backend/scripts/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,84 @@
"tags": []
},
{
"name": "Apple Krumb",
"name": "Blueberry",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/blueberry.jpg",
"description": "Blueberry donut",
"availability": false,
"tags": []
},
{
"name": "Boston Cream",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/boston_kreme.jpg",
"description": "Boston Cream",
"availability": true,
"tags": []
},
{
"name": "Chocolate Frosted",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/chocolate_frosted.jpg",
"description": "Chocolate Frosted",
"availability": true,
"tags": []
},
{
"name": "Chocolate Glaze",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/chocolate_glaze.jpg",
"description": "Chocolate Glaze",
"availability": true,
"tags": []
},
{
"name": "Chocolate Kreme",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/chocolate_kreme.jpg",
"description": "Chocolate Kreme",
"availability": true,
"tags": []
},
{
"name": "Cinnamon Sugar",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/cinnamon_sugar.jpg",
"description": "Cinnamon Sugar",
"availability": true,
"tags": []
},
{
"name": "Boston Cream",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/boston_kreme.jpg",
"description": "Boston Cream",
"availability": true,
"tags": []
},
{
"name": "Coconut",
"price": 3.99,
"weight": 10,
"discount": 0,
"picture": "https://cmu-17-356.github.io/Dronuts/assets/donut_flavors/coconut.jpg",
"description": "Coconut",
"availability": true,
"tags": []
}
]
}
11 changes: 9 additions & 2 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ import mongoose from 'mongoose';

import config from '../config.json';
import router from "./routes";

import cors from 'cors';

const app = express();
app.use(cors());
const jsonParser = bodyParser.json();
// const urlencoded = bodyParser.urlencoded({extended: false});
app.use(jsonParser);

app.use(router);

// app.use(express.json())
// app.use(express.urlencoded({ extended: false }));
const corsOptions ={
origin:'*',
credentials:true, //access-control-allow-credentials:true
optionSuccessStatus:200,
}
app.use(router);
app.use(express.static(__dirname + '/public'));

mongoose.connect(config.db, () => {
Expand Down
1 change: 1 addition & 0 deletions backend/src/models/customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const customerSchema: Schema = new Schema({

customerSchema.methods.toJSON = function () {
return {
id: this._id,
username: this.username,
password: this.password,
phoneNumber: this.phoneNumber,
Expand Down
9 changes: 7 additions & 2 deletions backend/src/models/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ const orderSchema: Schema = new Schema({
amounts: [Number],
status: {
type: String,
enum: ['IN-PROGRESS', 'IN-DELIVERY', 'COMPLETED'],
default: 'IN-PROGRESS'
enum: [
'UNCONFIRMED', // entered in the system by customer, but not yet confirmed
'IN-PROGRESS', // confirmed by customer
'IN-DELIVERY', // confirmed and set out by employee
'COMPLETED' // received by customer
],
default: 'UNCONFIRMED'
},
tax: Number,
serviceFee: Number,
Expand Down
Loading

0 comments on commit 2298fce

Please sign in to comment.