Skip to content

Commit

Permalink
Working API server and Deployment (#37)
Browse files Browse the repository at this point in the history
* Delete Angular Frontend

We're starting over with a Express, NodeJS, and ReactJS tech stack with MySQL.

* Add React Files

Added files that were created from create-react-app

* Remove .idea

Removed Intellij project files that were associated with the angular frontend.

* Organize DB files

* Create Dockerfiles

Create files for Docker deployment

* Fix typo

* Add Bootstrap Library

* Remove Service Worker

* Install ESLint

* Fix Files to Conform to Style Guide

I selected Airbnb style guide. We can always swtich

* Start Work on React Frontend Components

The plan should be to create basic components then to stich them together

* Add UFSIT logo

* Add WIP of Sidebar and Login component

I have to see how I could use react better to create this components. Because rn I'm looking at style and not functionality.

* Remove AWS integration and Google Calendar

* Install react-bootstrap

* Create Login Component

Functionality is still needed to be created

* Create UserManager Component

Purpose is to mange larger application state

* Remove AWS and Google Cal and Unneeded Routes

Routes like Resume, Writeups, and custom tiles

* Create component files

* Add server.js file to run API server

Completed additional refactoring of API server

* Add Docker-Compose.yml

Currently works for db service

* Fix SQL error on account creation

* Add comment

* Add Dockerfiles and edits to docker-compose.yml

* Fix Environment Variables

* Create Working Iteration of Docker Deployment

Good for dev and a good start for production

* Add Documentation for Others to Follow

Still need to do more investigation about the volume mounting for db
  • Loading branch information
SmoothHacker authored Sep 1, 2020
1 parent 44096b3 commit bfecaaa
Show file tree
Hide file tree
Showing 28 changed files with 1,417 additions and 781 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# dependencies
/node_modules
/Backend/node_modules
/.pnp
.pnp.js
Backend/.env

# testing
/coverage
Expand Down
13 changes: 13 additions & 0 deletions Backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:alpine

RUN mkdir -p /server
WORKDIR /server

COPY package*.json /server/

RUN npm install
COPY . /server/

EXPOSE 1337

CMD ["node", "server.js"]
29 changes: 2 additions & 27 deletions Backend/admin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const routes = require('express').Router(); // eslint-disable-line new-cap
const adminMgmt = require('./db/admin_mgmt.js');
// App-specific module imports
const util = require.main.require('./util');

const util = require.main.require('./utils');
const dbMgmt = require('./db/db_mgmt.js');

routes.get('/admin/list_users', async (req, res) => {
Expand All @@ -11,32 +12,6 @@ routes.get('/admin/list_users', async (req, res) => {
return res.status(403).send('Access denied');
});

routes.post('/admin/add_tile', async (req, res, next) => {
if (util.account_has_admin(req.account)) {
try {
await adminMgmt.add_tile(
req.body.name,
req.body.description,
req.body.link,
);
return res.status(200).send('Success');
} catch (error) { return next(error); }
} else {
return res.status(403).send('Access denied');
}
});

routes.post('/admin/delete_tile', async (req, res, next) => {
if (util.account_has_admin(req.account)) {
try {
await adminMgmt.delete_tile(req.body.id);
return res.status(200).send('Success');
} catch (error) { return next(error); }
} else {
return res.status(403).send('Access denied');
}
});

// Creating an election
routes.post('/admin/poll', async (req, res, next) => {
if (util.account_has_admin(req.account)) {
Expand Down
13 changes: 6 additions & 7 deletions Backend/app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
const routes = require('express').Router(); // eslint-disable-line new-cap
const app_mgmt = require('./db/app_mgmt.js');
const routes = require('express').Router();

routes.get('/app/custom_tiles', async (req, res, next) => res.status(200).json(await app_mgmt.custom_tiles()));
routes.get('/app/custom_tiles', async (req, res, next) => {

});

routes.post('/app/tile_click', async (req, res, next) => {
await app_mgmt.tile_click(req.session.account_id, req.body.id);
res.status(200).send('Success');

});

routes.post('/app/ctf_click', async (req, res, next) => {
await app_mgmt.ctf_click(req.session.account_id, req.body.id);
res.status(200).send('Success');

});

module.exports = routes;
10 changes: 0 additions & 10 deletions Backend/db/admin_mgmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,9 @@ const admin_mgmt_module = () => {
return await db_mgmt.list_users();
}

async function add_tile(name, description, link) {
return await db_mgmt.add_tile(name, description, link);
}

async function delete_tile(id) {
return await db_mgmt.delete_tile(id);
}

// Revealing Module: Return public interface
return ({
list_users,
add_tile,
delete_tile,
});
};

Expand Down
Loading

0 comments on commit bfecaaa

Please sign in to comment.