Back End delpoyed and hosted via Heroku
Deployed Site: Granted
In order for the app to function correctly, the user must set up their own environment variables.
create a .env file that includes the following:
-
PORT
- for local server settings -
JWT_SECRET
- secret for token verification -
DATABASE_URL
- set to the path your locally hosted version of the postgres database -
TEST_DATABASE_URL
- optional for a duplicate local database (empty) for testing purposes
To get the server running locally:
- Clone this repo
npm install
to install all required dependencies- add
.env
file for local environmental variables npm server
to start the local servernpm test
to start server using testing environment
- NodeJS
- Express
- Postgres
- Knex
- Jest
- Jsonwebtoken
- Bcryptjs
Method | Endpoint | Token Required? | Description |
---|---|---|---|
POST | /api/auth/register |
no | Adds new user, returns new user info |
POST | /api/auth/login |
no | Logs in existing user, returns token |
Method | Endpoint | Token Required? | Description |
---|---|---|---|
GET | / |
yes | Returns all writer profiles |
GET | /:userId |
yes | Returns specific writer profile |
PUT | /:userId |
yes | Updates writer profile |
Method | Endpoint | Token Required? | Description |
---|---|---|---|
GET | / |
yes | Returns work history for writer |
POST | / |
yes | Adds a work history by id |
PUT | /:workHistoryId |
yes | Updates a work history by id |
DELETE | /:workHistoryId |
yes | Deletes writer profile |
Method | Endpoint | Token Required? | Description |
---|---|---|---|
GET | / |
yes | Returns all applicant profiles |
GET | /:userId |
yes | Returns specific applicant profile |
PUT | /:userId |
yes | Updates applicant profile |
Method | Endpoint | Token Required? | Description |
---|---|---|---|
POST | /new |
yes | Creates a new grant |
GET | / |
yes | Returns all grants |
GET | /:grantId |
yes | Returns specific grant details |
DEL | /:grantId |
yes | Deletes a specific grant |
PUT | /:grantId |
yes | Updates grant details |
GET | /user/:userId/ |
yes | Returns all grants for a specific user |
{
id: UUID autogenerated,
email: STRING,
password: STRING,
user_type: STRING [ 'writer', 'applicant' ]
}
{
id: UUID autogenerated
writer_id: INTEGER foreign key in USERS table,
first_name: STRING,
last_name: STRING,
city: STRING,
state: STRING,
zip: STRING,
country: STRING,
sector: STRING,
website: STRING,
bio: STRING,
work_history: ARRAY
}
{
id: UUID autogenerated
applicant_id: INTEGER foreign key in USERS table,
first_name: STRING,
last_name: STRING,
city: STRING,
state: STRING,
zip: STRING,
country: STRING,
sector: STRING,
website: STRING,
bio: STRING,
org_name: STRING optional,
founding_date: DATE optional,
grants: ARRAY
}
{
id: UUID autogenerated,
applicant_profile_id: INTEGER (must refer to profile:id, NOT profile:applicant_id),
grant_name: STRING,
due_date: MM/DD/YYYY (saved as: YYYY-MM-DD3T00:00:00.000Z),
sector: STRING,
description: STRING,
site_id: STRING,
awarding_agency: STRING,
status: STRING OPTIONAL (default to "open")
},
add(user)
-> Adds new user, returns new user data
findById(id)
-> Returns a single user by ID
findByUserType(user_type)
-> Returns a single user by user type
findBy(filter)
-> Returns a single user by dynamic filter based on database
findWritersProfile()
-> Returns all writer profiles
findWriterProfileById(writer_id)
-> Returns a single writer by ID
findWriterProfileBy(filter)
-> Returns a single user by dynamic filter based on database
addWriterProfile(writer_id)
-> Adds new writer profile for existing writer ID, blank by default.
updateWriterProfile(writer_id, updatedData)
-> Update writer profile by writer ID
deleteWriterProfile(writer_id)
-> Delete writer profile by ID
addWorkHistory(body)
-> Adds new work history to an existing writer, returns updated writer profile object
updateWorkHistory(writer_id, updatedData)
-> Update work history to an existing writer, returns updated writer profile object
deleteWorkHistory(workHistId, writer_id)
-> Delete a work history writer by ID
findApplicantProfiles()
-> Returns all applicant profiles
findApplicantProfileById(applicant_id)
-> Returns a single writer by ID
findApplicantProfilesBy(filter)
-> Returns user(s) by dynamic filter based on database columns.
addApplicantProfile(applicant_id)
-> Adds new writer profile for existing writer ID, blank by default.
updateApplicantProfile(applicant_id, updatedData)
-> Update writer profile by writer ID
findGrants()
-> Returns all grants
findSingleGrantById(id)
-> Returns a single grant by the grant id.
findGrantsByUser(user_id)
-> Returns all grants by a single user id.
findGrantsBy(filter)
-> Returns all grants by dynamic filter based on database
findSingleGrantBy(filter)
-> Returns a single grant by dynamic filter based on database
addGrant({details})
-> Adds new grant details.
updateGrant(changes, grant_id)
-> Update a grant based on the grant ID
deleteGrant(id)
-> Deletes a single grant by the grant id.
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Please note we have a code of conduct. Please follow it in all your interactions with the project.
If you are having an issue with the existing project code, please submit a bug report under the following guidelines:
- Check first to see if your issue has already been reported.
- Check to see if the issue has recently been fixed by attempting to reproduce the issue using the latest master branch in the repository.
- Create a live example of the problem.
- Submit a detailed bug report including your environment & browser, steps to reproduce the issue, actual and expected outcomes, where you believe the issue is originating from, and any potential solutions you have considered.
We would love to hear from you about new features which would improve this app and further the aims of our project. Please provide as much detail and information as possible to show us why you think your new feature should be implemented.
If you have developed a patch, bug fix, or new feature that would improve this app, please submit a pull request. It is best to communicate your ideas with the developers first before investing a great deal of time into a pull request to ensure that it will mesh smoothly with the project.
Remember that this project is licensed under the MIT license, and by submitting a pull request, you agree that your work will be, too.
- Ensure any install or build dependencies are removed before the end of the layer when doing a build.
- Update the README.md with details of changes to the interface, including new plist variables, exposed ports, useful file locations and container parameters.
- Ensure that your code conforms to our existing code conventions and test coverage.
- Include the relevant issue number, if applicable.
- You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.
These contribution guidelines have been adapted from this good-Contributing.md-template.
See Front End Repo for details on the fronend of our project.