Skip to content

Commit

Permalink
Merge pull request #6 from chriseugenerodriguez/ci-cd
Browse files Browse the repository at this point in the history
Split Website & API
  • Loading branch information
chriseugenerodriguez authored Jan 2, 2024
2 parents df28dfc + 3c5fe94 commit 3b92add
Show file tree
Hide file tree
Showing 956 changed files with 366 additions and 315 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run build
- name: Build & Deploy Website
run: npm ci && npm run build
working-directory: ./website
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
entryPoint: ./website
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GRCERI_C3702 }}'
channelId: live
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run build
- name: Build & Deploy Website
run: npm ci && npm run build
working-directory: ./website
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
entryPoint: ./website
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_GRCERI_C3702 }}'
projectId: grceri-c3702
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/misc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const environmentConfigs = {
},
};
// Recursively merge configurations
export default _.merge(defaultConfig, environmentConfigs[process.env.NODE_ENV] || {});
export default _.merge(defaultConfig, environmentConfigs[process.env.NODE_ENV] || {});
46 changes: 23 additions & 23 deletions api/misc/error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import Constants from './constants';

export default function errorHandler(err, req, res, next) {
if (!err) {
return res.sendStatus(500);
}

if (err.response && err.response['status'] !== 500) {
const errorResponse = err.response;
res.status(err.response['status']).json(errorResponse.data);
} else {
const error = {
message: err.message || 'Internal Server Error.',
stack: '',
};

if (Constants.envs.development) {
error.stack = err.stack;
}

res.status((err.response && err.response.status) || 500).json(error);
}
}
import Constants from './constants';

export default function errorHandler(err, req, res, next) {
if (!err) {
return res.sendStatus(500);
}

if (err.response && err.response['status'] !== 500) {
const errorResponse = err.response;
res.status(err.response['status']).json(errorResponse.data);
} else {
const error = {
message: err.message || 'Internal Server Error.',
stack: '',
};

if (Constants.envs.development) {
error.stack = err.stack;
}

res.status((err.response && err.response.status) || 500).json(error);
}
}
58 changes: 29 additions & 29 deletions api/routes.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { Router } from 'express';

// ROUTES
import MiscRoutes from './routes/misc.route';
import ListsRoutes from './routes/lists.route';
import ProductRoutes from './routes/product.route';
import SearchRoutes from './routes/search.route';
import TransactionRoutes from './routes/transaction.route';
import UserRoutes from './routes/user.route';
import RegisterRoutes from './routes/register.route';
import errorHandler from './misc/error-handler';

// ROUTER
export const routes = Router();

// REFERENCE
routes.use('/misc', MiscRoutes);
routes.use('/products', ProductRoutes);
routes.use('/search', SearchRoutes);
routes.use('/users', UserRoutes);
routes.use('/user', UserRoutes);
routes.use('/transactions', TransactionRoutes);
routes.use('/lists', ListsRoutes);
routes.use('/register', RegisterRoutes);

// ERROR
routes.use(errorHandler);

export default routes;
import { Router } from 'express';

// ROUTES
import MiscRoutes from './routes/misc.route';
import ListsRoutes from './routes/lists.route';
import ProductRoutes from './routes/product.route';
import SearchRoutes from './routes/search.route';
import TransactionRoutes from './routes/transaction.route';
import UserRoutes from './routes/user.route';
import RegisterRoutes from './routes/register.route';
import errorHandler from './misc/error-handler';

// ROUTER
export const routes = Router();

// REFERENCE
routes.use('/misc', MiscRoutes);
routes.use('/products', ProductRoutes);
routes.use('/search', SearchRoutes);
routes.use('/users', UserRoutes);
routes.use('/user', UserRoutes);
routes.use('/transactions', TransactionRoutes);
routes.use('/lists', ListsRoutes);
routes.use('/register', RegisterRoutes);

// ERROR
routes.use(errorHandler);

export default routes;
30 changes: 15 additions & 15 deletions api/routes/lists.route.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
Router
} from 'express';

import ListAPI from '../functions/lists.functions';

const routes = Router();

routes.route('/followed').get(ListAPI.getMostFollowedLists);
routes.route('/viewed').get(ListAPI.getMostViewedProducts);
routes.route('/viewed/:productId').get(ListAPI.getMostViewedProductsID);
routes.route('/watched').get(ListAPI.getMostWatchedLists);
routes.route('/watched/:productId').get(ListAPI.getMostWatchedListsID);

export default routes;
import {
Router
} from 'express';

import ListAPI from '../functions/lists.functions';

const routes = Router();

routes.route('/followed').get(ListAPI.getMostFollowedLists);
routes.route('/viewed').get(ListAPI.getMostViewedProducts);
routes.route('/viewed/:productId').get(ListAPI.getMostViewedProductsID);
routes.route('/watched').get(ListAPI.getMostWatchedLists);
routes.route('/watched/:productId').get(ListAPI.getMostWatchedListsID);

export default routes;
26 changes: 13 additions & 13 deletions api/routes/misc.route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
Router,
} from 'express';

import MiscAPI from '../functions/misc.functions';

const routes = Router();

routes.route('/categories').get(MiscAPI.getCategories);

routes.route('/search/:value').get(MiscAPI.search);

export default routes;
import {
Router,
} from 'express';

import MiscAPI from '../functions/misc.functions';

const routes = Router();

routes.route('/categories').get(MiscAPI.getCategories);

routes.route('/search/:value').get(MiscAPI.search);

export default routes;
80 changes: 40 additions & 40 deletions api/routes/product.route.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import {
Router,
} from 'express';

import ProductsAPI from '../functions/products.functions';

const routes = Router();

routes.route('/').get(ProductsAPI.getProducts);

routes.route('/search').get(ProductsAPI.searchProducts);

routes.route('/sidebarFilters').get(ProductsAPI.getSidebarFilters);

routes.route('/:upc').get(ProductsAPI.getProduct);

// single product
routes.route('/product/details/:productId')
.get(ProductsAPI.getProductDetails);
routes.route('/product/images/:productId')
.get(ProductsAPI.getProductImages);
routes.route('/product/nutrition/:productId')
.get(ProductsAPI.getProductNutrition);
routes.route('/product/vendors/:productId')
.get(ProductsAPI.getProductVendors);
routes.route('/product/overview/:productId')
.get(ProductsAPI.getProductOverview);
routes.route('/product/history/:productId/:time')
.get(ProductsAPI.getProductHistory);

// product feedback
routes.route('product/feedback').post(ProductsAPI.postFeedback);

routes.route('/product/get_pricing_plans')
.get(ProductsAPI.getPricingPlans);

routes.route('/product/postTransactions')
.post(ProductsAPI.postTransaction);

export default routes;
import {
Router,
} from 'express';

import ProductsAPI from '../functions/products.functions';

const routes = Router();

routes.route('/').get(ProductsAPI.getProducts);

routes.route('/search').get(ProductsAPI.searchProducts);

routes.route('/sidebarFilters').get(ProductsAPI.getSidebarFilters);

routes.route('/:upc').get(ProductsAPI.getProduct);

// single product
routes.route('/product/details/:productId')
.get(ProductsAPI.getProductDetails);
routes.route('/product/images/:productId')
.get(ProductsAPI.getProductImages);
routes.route('/product/nutrition/:productId')
.get(ProductsAPI.getProductNutrition);
routes.route('/product/vendors/:productId')
.get(ProductsAPI.getProductVendors);
routes.route('/product/overview/:productId')
.get(ProductsAPI.getProductOverview);
routes.route('/product/history/:productId/:time')
.get(ProductsAPI.getProductHistory);

// product feedback
routes.route('product/feedback').post(ProductsAPI.postFeedback);

routes.route('/product/get_pricing_plans')
.get(ProductsAPI.getPricingPlans);

routes.route('/product/postTransactions')
.post(ProductsAPI.postTransaction);

export default routes;
24 changes: 12 additions & 12 deletions api/routes/register.route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
Router,
} from 'express';

import RegisterAPI from '../functions/register.functions';

const routes = Router();

routes.route('/:phone')
.post(RegisterAPI.registerPhoneNumber);

export default routes;
import {
Router,
} from 'express';

import RegisterAPI from '../functions/register.functions';

const routes = Router();

routes.route('/:phone')
.post(RegisterAPI.registerPhoneNumber);

export default routes;
34 changes: 17 additions & 17 deletions api/routes/search.route.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
Router,
} from 'express';

import SearchAPI from '../functions/search.functions';

const routes = Router();

routes.route('/sidebar').get(SearchAPI.getSearchPageSidebar);

routes.route('/content').get(SearchAPI.getSearchPageContent);

routes.route('/url/exists').post(SearchAPI.searchUrlExists);

// routes.route('/:upc').get(ProductsAPI.getProduct);

export default routes;
import {
Router,
} from 'express';

import SearchAPI from '../functions/search.functions';

const routes = Router();

routes.route('/sidebar').get(SearchAPI.getSearchPageSidebar);

routes.route('/content').get(SearchAPI.getSearchPageContent);

routes.route('/url/exists').post(SearchAPI.searchUrlExists);

// routes.route('/:upc').get(ProductsAPI.getProduct);

export default routes;
50 changes: 25 additions & 25 deletions api/routes/transaction.route.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {
Router,
} from 'express';

import TransactionsAPI from '../functions/transactions.functions';

const routes = Router();

routes.route('/:uid')
.get(TransactionsAPI.getTransactions)
.post(TransactionsAPI.postTransaction);

routes.route('/:uid/:tid')
.get(TransactionsAPI.getTransaction)
.put(TransactionsAPI.updateTransaction);

routes.route('/transaction/get_pricing_plans')
.get(TransactionsAPI.getPricingPlans);

// routes.route('/get_pricing_plans')
// .get(function(req, res, next){
// console.log('Hello');
// });

export default routes;
import {
Router,
} from 'express';

import TransactionsAPI from '../functions/transactions.functions';

const routes = Router();

routes.route('/:uid')
.get(TransactionsAPI.getTransactions)
.post(TransactionsAPI.postTransaction);

routes.route('/:uid/:tid')
.get(TransactionsAPI.getTransaction)
.put(TransactionsAPI.updateTransaction);

routes.route('/transaction/get_pricing_plans')
.get(TransactionsAPI.getPricingPlans);

// routes.route('/get_pricing_plans')
// .get(function(req, res, next){
// console.log('Hello');
// });

export default routes;
Loading

0 comments on commit 3b92add

Please sign in to comment.