Skip to content

Commit

Permalink
Merge branch 'mic'
Browse files Browse the repository at this point in the history
  • Loading branch information
ML-Chen committed Apr 29, 2020
2 parents 6edc224 + 504ac00 commit 013468b
Show file tree
Hide file tree
Showing 239 changed files with 803 additions and 16,399 deletions.
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# StoreStash

App for CS 4261: Mobile Apps & Services.
App for CS 4261: Mobile Apps & Services, Spring 2020.

2nd place winner of the [Georgia Tech Convergence Innovation Competition: Global Response](http://www.cic.gatech.edu/).

## Running locally

Expand Down Expand Up @@ -29,23 +31,40 @@ Install dependencies: `npm install`

Serve the app: `npm start`

## Deploying
## Deploying to Heroku

Some helpful commands for pushing the subfolders to Heroku:
Install the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli), and then set it up:

```bash
npm install -g heroku
npm install -g heroku # adds the heroku command to CLI on Windows
heroku login
```

# Add Heroku remote
heroku git:remote -a storestash # or…
Add Heroku remote. Replace the URLs here with the ones for your Heroku app.

```bash
git remote add storestash-app-heroku https://git.heroku.com/storestash-app.git
git remote add storestash-backend-heroku https://git.heroku.com/storestash.git
```

For the following instructions, make sure your command line is in the StoreStash folder, not backend/ or react_ionic

Push from the master branch (non-force):

# cd to StoreStash folder, not backend/ or react_ionic
```bash
git subtree push --prefix frontend storestash-app-heroku master
git subtree push --prefix backend storestash-backend-heroku master
```

# Push
git subtree push --prefix backend heroku master
Force push from the master branch:

```bash
git push storestash-app-heroku `git subtree split --prefix frontend master`:master --force
git push storestash-app-heroku `git subtree split --prefix backend master`:master --force
```

Other commands that may be helpful:
```bash
# Force push from local end_to_end branch
git push heroku `git subtree split --prefix backend end_to_end`:master --force
heroku logs -a storestash
Expand Down
2 changes: 2 additions & 0 deletions backend/LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Portions from Microsoft's TypeScript Node Starter (https://github.com/microsoft/TypeScript-Node-Starter/) fall under the MIT License, by Bowden Kelly. Other parts are copyrighted by Michael Chen and Gabe Wilson.

MIT License

Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down
6 changes: 3 additions & 3 deletions backend/copyStaticAssets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as shell from "shelljs";

shell.cp("-R", "src/public/js/lib", "dist/public/js/");
shell.cp("-R", "src/public/fonts", "dist/public/");
shell.cp("-R", "src/public/images", "dist/public/");
// shell.cp("-R", "src/public/js/lib", "dist/public/js/");
// shell.cp("-R", "src/public/fonts", "dist/public/");
// shell.cp("-R", "src/public/images", "dist/public/");
1,981 changes: 596 additions & 1,385 deletions backend/package-lock.json

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@
"type": "git",
"url": "https://github.com/Microsoft/TypeScript-Node-Starter"
},
"author": "Bowden Kelly",
"license": "MIT",
"author": "Michael Chen, Gabe Wilson",
"scripts": {
"start": "npm run serve",
"build": "npm run build-sass && npm run build-ts && npm run copy-static-assets",
"build": "npm run build-ts && npm run copy-static-assets",
"serve": "node dist/server.js",
"watch-node": "nodemon dist/server.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run watch-node\"",
"watch": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run watch-node\"",
"test": "jest --forceExit --coverage --verbose",
"watch-test": "npm run test -- --watchAll",
"build-ts": "tsc",
"watch-ts": "tsc -w",
"build-sass": "node-sass src/public/css/main.scss dist/public/css/main.css",
"watch-sass": "node-sass -w src/public/css/main.scss dist/public/css/main.css",
"lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
"copy-static-assets": "ts-node copyStaticAssets.ts",
"debug": "npm run build && npm run watch-debug",
"serve-debug": "nodemon --inspect dist/server.js",
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve-debug\""
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-ts\" \"npm run serve-debug\""
},
"dependencies": {
"@types/bcrypt": "^3.0.0",
Expand Down Expand Up @@ -97,7 +94,7 @@
"chai": "^4.2.0",
"concurrently": "^5.2.0",
"eslint": "^6.8.0",
"jest": "^25.4.0",
"jest": "^25.5.1",
"node-sass": "^4.14.0",
"nodemon": "^2.0.3",
"shelljs": "^0.8.4",
Expand Down
6 changes: 0 additions & 6 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ import jwt from "jsonwebtoken";
const MongoStore = mongo(session);

// Controllers (route handlers)
import * as homeController from "./controllers/home";
import * as userController from "./controllers/user";
import * as apiController from "./controllers/api";
import * as contactController from "./controllers/contact";


// API keys and Passport configuration
import * as passportConfig from "./config/passport";

// Create Express server
const app = express();
Expand Down
156 changes: 0 additions & 156 deletions backend/src/config/passport.ts

This file was deleted.

31 changes: 16 additions & 15 deletions backend/src/controllers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ type UserJson = {
facebook: string;
tokens: {accessToken: string; kind: string}[];

profile: {
name: string;
gender: string;
location: string;
website: string;
picture: string;
};
phone: string;
firstName: string;
lastName: string
gender: string;
location: string;
website: string;
picture: string;
}

type RentalJson = {
Expand Down Expand Up @@ -63,7 +63,7 @@ type MongoJson = {
export const login = async (req: Request, res: Response) => {
try {
const user: any = await User.findOne({ email: req.body.email });
user.comparePassword(req.body.password, (err, isMatch) => {
user.comparePassword(req.body.password, (err: any, isMatch: any) => {
if (err) {
console.log(err);
res.status(400).send(err);
Expand All @@ -90,7 +90,7 @@ export const login = async (req: Request, res: Response) => {
*/
export const newUser = async (req: Request, res: Response) => {
try {
const user = await (User as unknown as UserDocument).construct(req.body.email, req.body.password, req.body.phone, req.body.firstName, req.body.lastName);
const user = await (User as unknown as UserDocument).construct(req.body.email, req.body.password, req.body.firstName, req.body.lastName, req.body.phone);
console.log(user);
res.json({ ...user.toObject(), gravatar: user.gravatar() });
} catch (err) {
Expand All @@ -106,7 +106,7 @@ export const newUser = async (req: Request, res: Response) => {
export const getRentalHistory = async (req: Request, res: Response) => {
try {
const history = await (Rental as unknown as RentalDocument).listRenterHistory(req.params.id);
res.json(history.map(rental => { return { ...(rental.toObject()), name: rental.host.firstName + " " + rental.host.lastName };}));
res.json(history.map((rental: any) => { return { ...(rental.toObject()), name: rental.host.firstName + " " + rental.host.lastName };}));
} catch (err) {
res.status(400).send(err);
}
Expand All @@ -120,7 +120,7 @@ export const getRentalHistory = async (req: Request, res: Response) => {
export const getLendingHistory = async (req: Request, res: Response) => {
try {
const history = await (Rental as unknown as RentalDocument).listLenderHistory(req.params.id);
res.json(history.map(rental => {return { ...(rental.toObject()), name: rental.renter.firstName + " " + rental.renter.lastName };}));
res.json(history.map((rental: any) => {return { ...(rental.toObject()), name: rental.renter.firstName + " " + rental.renter.lastName };}));
} catch (err) {
res.status(400).send(err);
}
Expand All @@ -135,11 +135,12 @@ export const getLendingHistory = async (req: Request, res: Response) => {
* @param {string} req.body.startDate
* @param {string} req.body.endDate
* @param {number} req.body.price
* @param {string} req.body.image
* Response: the new Listing
*/
export const newListing = async (req: Request, res: Response) => {
try {
const listing = await (Listing as unknown as ListingDocument).construct(req.body.hostId, req.body.lat, req.body.lon, req.body.capacity, new Date(req.body.startDate), new Date(req.body.endDate), req.body.price);
const listing = await (Listing as unknown as ListingDocument).construct(req.body.hostId, req.body.lat, req.body.lon, req.body.capacity, new Date(req.body.startDate), new Date(req.body.endDate), req.body.price, req.body.image);
await res.json(listing.toObject());
} catch (err) {
console.log(err);
Expand Down Expand Up @@ -190,9 +191,9 @@ export const rentListing = async (req: Request, res: Response) => {
*/
export const getNearby = async (req: Request, res: Response) => {
try {
const startDate = req.query.startDate ? new Date(req.query.startDate) : undefined;
const endDate = req.query.endDate ? new Date(req.query.endDate) : undefined;
const listings = await (Listing as unknown as ListingDocument).getNearby(req.query.lat, req.query.lon, req.query.minCapacity, req.query.maxPrice, startDate, endDate);
const startDate = req.query.startDate ? new Date(req.query.startDate as string) : undefined;
const endDate = req.query.endDate ? new Date(req.query.endDate as string) : undefined;
const listings = await (Listing as unknown as ListingDocument).getNearby(req.query.lat as any as number, req.query.lon as any as number, req.query.minCapacity as any as number, req.query.maxPrice as any as number, startDate, endDate);
res.json(listings);
} catch (err) {
res.status(400).send(err);
Expand Down
Loading

0 comments on commit 013468b

Please sign in to comment.