This project was bootstrapped with Create React App.
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
In order for the tests and provided front-end to run properly, you will need to make sure to:
- Create and export your Express app from a root-level file called server.js
- Accept and set an optional port argument for your server to listen on from
process.env.PORT
- If
process.env.PORT
is not set, server should run on port4000
(this is where the provided front-end will make requests to) - Accept and set an optional database file argument from
process.env.TEST_DATABASE
in all Express route files that open and modify your database - Use the root-level database.sqlite as your API's database
- Note: When loading database.sqlite in your JavaScript files, sqlite3 will always try to load database.sqlite from the root directory path,
./database.sqlite
, regardless of where the current file is located. Therefore your code will always benew sqlite3.Database(process.env.TEST_DATABASE || './database.sqlite')
regardless of the file you are writing in
-
Employee
- id - Integer, primary key, required
- name - Text, required
- position - Text, required
- wage - Integer, required
- is_current_employee - Integer, defaults to
1
-
Timesheet
- id - Integer, primary key, required
- hours - Integer, required
- rate - Integer, required
- date - Integer, required
- employee_id - Integer, foreign key, required
-
Menu
- id - Integer, primary key, required
- title - Text, required
-
MenuItem
- id - Integer, primary key, required
- name - Text, required
- description - Text, optional
- inventory - Integer, required
- price - Integer, required
- menu_id - Integer, foreign key, required
/api/employees
- GET
- Returns a 200 response containing all saved currently-employed employees (
is_current_employee
is equal to1
) on theemployees
property of the response body
- Returns a 200 response containing all saved currently-employed employees (
- POST
- Creates a new employee with the information from the
employee
property of the request body and saves it to the database. Returns a 201 response with the newly-created employee on theemployee
property of the response body - If any required fields are missing, returns a 400 response
- Creates a new employee with the information from the
/api/employees/:employeeId
- GET
- Returns a 200 response containing the employee with the supplied employee ID on the
employee
property of the response body - If an employee with the supplied employee ID doesn't exist, returns a 404 response
- Returns a 200 response containing the employee with the supplied employee ID on the
- PUT
- Updates the employee with the specified employee ID using the information from the
employee
property of the request body and saves it to the database. Returns a 200 response with the updated employee on theemployee
property of the response body - If any required fields are missing, returns a 400 response
- If an employee with the supplied employee ID doesn't exist, returns a 404 response
- Updates the employee with the specified employee ID using the information from the
- DELETE
- Updates the employee with the specified employee ID to be unemployed (
is_current_employee
equal to0
). Returns a 200 response. - If an employee with the supplied employee ID doesn't exist, returns a 404 response
- Updates the employee with the specified employee ID to be unemployed (
/api/employees/:employeeId/timesheets
- GET
- Returns a 200 response containing all saved timesheets related to the employee with the supplied employee ID on the
timesheets
property of the response body - If an employee with the supplied employee ID doesn't exist, returns a 404 response
- Returns a 200 response containing all saved timesheets related to the employee with the supplied employee ID on the
- POST
- Creates a new timesheet, related to the employee with the supplied employee ID, with the information from the
timesheet
property of the request body and saves it to the database. Returns a 201 response with the newly-created timesheet on thetimesheet
property of the response body - If any required fields are missing, returns a 400 response
- If an employee with the supplied employee ID doesn't exist, returns a 404 response
- Creates a new timesheet, related to the employee with the supplied employee ID, with the information from the
/api/employees/:employeeId/timesheets/:timesheetId
- PUT
- Updates the timesheet with the specified timesheet ID using the information from the
timesheet
property of the request body and saves it to the database. Returns a 200 response with the updated timesheet on thetimesheet
property of the response body - If any required fields are missing, returns a 400 response
- If an employee with the supplied employee ID doesn't exist, returns a 404 response
- If an timesheet with the supplied timesheet ID doesn't exist, returns a 404 response
- Updates the timesheet with the specified timesheet ID using the information from the
- DELETE
- Deletes the timesheet with the supplied timesheet ID from the database. Returns a 204 response.
- If an employee with the supplied employee ID doesn't exist, returns a 404 response
- If an timesheet with the supplied timesheet ID doesn't exist, returns a 404 response
/api/menus
- GET
- Returns a 200 response containing all saved menus on the
menus
property of the response body
- Returns a 200 response containing all saved menus on the
- POST
- Creates a new menu with the information from the
menu
property of the request body and saves it to the database. Returns a 201 response with the newly-created menu on themenu
property of the response body - If any required fields are missing, returns a 400 response
- Creates a new menu with the information from the
/api/menus/:menuId
- GET
- Returns a 200 response containing the menu with the supplied menu ID on the
menu
property of the response body - If a menu with the supplied menu ID doesn't exist, returns a 404 response
- Returns a 200 response containing the menu with the supplied menu ID on the
- PUT
- Updates the menu with the specified menu ID using the information from the
menu
property of the request body and saves it to the database. Returns a 200 response with the updated menu on themenu
property of the response body - If any required fields are missing, returns a 400 response
- If a menu with the supplied menu ID doesn't exist, returns a 404 response
- Updates the menu with the specified menu ID using the information from the
- DELETE
- Deletes the menu with the supplied menu ID from the database if that menu has no related menu items. Returns a 204 response.
- If the menu with the supplied menu ID has related menu items, returns a 400 response.
- If a menu with the supplied menu ID doesn't exist, returns a 404 response
/api/menus/:menuId/menu-items
- GET
- Returns a 200 response containing all saved menu items related to the menu with the supplied menu ID on the
menu items
property of the response body - If a menu with the supplied menu ID doesn't exist, returns a 404 response
- Returns a 200 response containing all saved menu items related to the menu with the supplied menu ID on the
- POST
- Creates a new menu item, related to the menu with the supplied menu ID, with the information from the
menuItem
property of the request body and saves it to the database. Returns a 201 response with the newly-created menu item on themenuItem
property of the response body - If any required fields are missing, returns a 400 response
- If a menu with the supplied menu ID doesn't exist, returns a 404 response
- Creates a new menu item, related to the menu with the supplied menu ID, with the information from the
/api/menus/:menuId/menu-items/:menuItemId
- PUT
- Updates the menu item with the specified menu item ID using the information from the
menuItem
property of the request body and saves it to the database. Returns a 200 response with the updated menu item on themenuItem
property of the response body - If any required fields are missing, returns a 400 response
- If a menu with the supplied menu ID doesn't exist, returns a 404 response
- If a menu item with the supplied menu item ID doesn't exist, returns a 404 response
- Updates the menu item with the specified menu item ID using the information from the
- DELETE
- Deletes the menu item with the supplied menu item ID from the database. Returns a 204 response.
- If a menu with the supplied menu ID doesn't exist, returns a 404 response
- If a menu item with the supplied menu item ID doesn't exist, returns a 404 response
A testing suite has been provided for you, checking for all essential functionality and edge cases.
To run these tests, first, open the root project directory in your terminal. Then run npm install
to install
all necessary testing dependencies (if you haven't already).
Finally, run npm test
. You will see a list of tests that ran with information
about whether or not each test passed. After this list, you will see more specific output
about why each failing test failed.
As you implement functionality, run the tests to ensure you are creating correctly named variables and functions that return the proper values. The tests will additionally help you identify edge cases that you may not have anticipated when first writing the functions.