Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create applications #8

Merged
merged 39 commits into from
Sep 17, 2019
Merged

Create applications #8

merged 39 commits into from
Sep 17, 2019

Conversation

seanjparker
Copy link
Collaborator

@seanjparker seanjparker commented Sep 3, 2019

For issues #1
This pull request implements applications along with a basic error handler and dashboard

Features:

  • Applications form (front-end)
  • Application router + controller
  • Basic dashboard (front-end)
  • Caching of application questions
  • Dependency injection for controllers, services, cache
  • Testing using Ava and ts-mockito
  • CV uploads to Dropbox
  • Storage of applications in MySQL DB

It it quite simple to add new hackathon questions, only a few files need to be modified but with some more work it could be better (this can be for future work)

Routes:

  • GET /apply
  • POST /apply
  • GET /

You can test out the routes using Postman and import the Postman Collection

@seanjparker seanjparker added the feature New feature or request label Sep 3, 2019
@seanjparker seanjparker added this to the GUH19 Applications Open milestone Sep 3, 2019
@seanjparker seanjparker requested a review from a team September 3, 2019 15:02
@seanjparker seanjparker self-assigned this Sep 3, 2019
@kzalys
Copy link
Contributor

kzalys commented Sep 3, 2019

I can't see any tests. Will they be coming later?

@seanjparker
Copy link
Collaborator Author

I can't see any tests. Will they be coming later?

There are a couple of things I need to add, like CV support
And yes, the tests will be coming in this PR

@kzalys
Copy link
Contributor

kzalys commented Sep 4, 2019

I can't see any tests. Will they be coming later?

There are a couple of things I need to add, like CV support
And yes, the tests will be coming in this PR

Alright, do you want me to wait for the changes or should review the PR now?

@seanjparker
Copy link
Collaborator Author

I can't see any tests. Will they be coming later?

There are a couple of things I need to add, like CV support
And yes, the tests will be coming in this PR

Alright, do you want me to wait for the changes or should review the PR now?

Wait for the changes, hopefully it will be done by this weekend

Copy link
Contributor

@kzalys kzalys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The application form looks really cool and I love how smart the questions system is!

I left a few suggestions below.

.env.example Outdated Show resolved Hide resolved
Makefile Outdated
@@ -25,12 +25,12 @@ setup-network:

# starts the app and MySQL in docker containers
up: build-docker setup-network
@echo "=============starting hs_hub============="
@echo "=============starting hs_application============="
docker-compose up -d

# starts the app and MySQL in docker containers for dev environment
up-dev: build-docker-dev setup-network
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a big deal but I'd say that it's better to just start the app on the host for a dev environment. Based on my experience working on hs_auth, it's not fun working on an app that is running in a container since you need to restart the container (and rebuild the image in this case) whenever you add any new dependencies or change any env variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found the same 😂I will include a separate docker-compose for dev environments that will launch only the DB

@@ -19,7 +19,6 @@ services:
command: --default-authentication-plugin=mysql_native_password --log_error_verbosity=1
environment:
MYSQL_ROOT_PASSWORD: root
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this should be set in a .env file because people might forget to change the root password if it's hidden inside the docker-compose file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, true. I should write a script that creates a new user since having the root user is bad practice anyway

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create an issue for this if you're not going to do it in this diff?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be in this PR, I think I have a fix for the problem I was having

src/app.ts Outdated
*/
private devMiddlewareSetup = (app: Express): void => {
// Development environment set up
if (app.get("env") === "dev") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be cleaner if this check was done prior to calling devMiddlewareSetup because it's not evident from the method's name or the comment that env has to be set to dev for this method to do anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I agree. Good catch


/**
* Loads the applications settings into Cache
* Questions are stored under the name `Questions`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the questions not stored under Sections? That's the name of the class right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to change this! Initially it was called Questions but then I changed to storing the questions in sections

this.statusCode = _statusCode;
this.message = _message;

switch (this.statusCode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could replace this switch by defining a map where the key is the response code and the value is the error message and then just call the map.

Though you would need to also add an if for when the response code is not in the map but it should still be cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would be cleaner. I just stole this from hs_hub for now. I will rework this when I get round to it. I've created another issue for improving the error handling (see #10)

}

console.error(err.stack);
res.status(HttpResponseCode.INTERNAL_ERROR).send(new ApiError(HttpResponseCode.INTERNAL_ERROR, err.stack));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be a great idea to send the entire error stack trace to the user in prod as it might contain some sensitive information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I'll change this

@@ -2,6 +2,7 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file still contains instructions for hs_hub but fixing this isn't urgent tbh

@@ -19,7 +19,6 @@ services:
command: --default-authentication-plugin=mysql_native_password --log_error_verbosity=1
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: hub
ports:
- "${DB_PORT}:${DB_PORT}"
# The healthcheck is used to ensure the database is running before the hub starts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says: before the hub starts

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 😊

@@ -3,6 +3,8 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to somehow indicate which fields are required but I'm guessing that is not a trivial change since the form is generated dynamically

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am working on this, just thinking about how to design it. The questions all have a setting called required so it shouldn’t be too difficult.

Right now the required inputs turn red when you click and purple otherwise but it should be made clearer

kzalys
kzalys previously approved these changes Sep 17, 2019
Copy link
Contributor

@kzalys kzalys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

@seanjparker seanjparker merged commit cdb9bbc into master Sep 17, 2019
@seanjparker seanjparker deleted the create-applications branch September 17, 2019 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants