-
Notifications
You must be signed in to change notification settings - Fork 0
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
As a user I should be able to sign up for Chaat #1
Labels
feature
New feature or request
Comments
The PR for this story includes local server + db setup along with user account creation/deletion functionality. Still a few important tasks to finish:
|
Remaining tasks will be completed by Monday. |
shahn95
added a commit
that referenced
this issue
Jul 26, 2023
Story: As a user I should be able to sign up for Chaat (#1) This PR also includes local server + db setup along with user account creation/deletion functionality. * Test commit * Update health-check-test * Update project.clj dependencies * Initialize docker-compose file for local postgresql db * Update Dockerfile * Initialize config.clj to parse config.edn * Initialize config file * Initialize up/down migration files for users table * Initialize migrations.clj to apply/rollback migrations * Initialize model/user.clj with wip user account create/delete functions * Add wrap-params, wrap-keyword-params, and wrap-json-params middleware * Add routes for signup and delete-user, and filter on request methods * Update handler.clj with handlers for signup and delete-account * Update intro foo * Update dependencies * Start using a map return structure and move username/password validation from model -> handler layer This is wip, and a checkpoint to document progress. I plan to refactor this later to try a tuple return structure, and have different validations at both handler and model layers. More on that in a future commit. Started implementing a 3 key map (:success, :message, :description) to unify return values from validation functions and db operations. Goal is to simplify passing success/error info back to the handler layer. Created fn build-result-map to simplify construction of the returned map. Created fn send-response to send a good/bad response based on the returned map. Created fn gen-new-user-map to generate a map with all data required to insert a new user into the db. * Create handler folder and refactor with tuple return structure. Move validation into validation.clj Moved validation out of handler.clj and into validation.clj Moved handler.clj and validation.clj into handler folder. Refactored handler.clj to use a tuple return structure for error handling and validation: [params nil] or [nil err-msg] Updated handler level validation to only check that required parameters exist. I plan to add more robust validation using a library like schema in a future commit. * Refactor with tuple return structure and remove db queries. Add model layer validation. Removed db queries from this layer will go into a separate db layer in the next commit. * Initialize db layer with user related (new?/add/delete) db queries Creates a connection pooled datasource and performs queries on the user table to check if users exists along with adding/deleting users. This also uses a tuple return structure. * Update to use callable functions: run-migrations and rollback * Update to use callable functions to fetch config info * Add config to setup a different db instance to run tests on * Update dependencies * Add start/stop/restart functions, update middleware order, and use local server port from config. * Update new-user? function to receive datasource as a parameter This is necessary if new-user? is to be used within a db transaction * Refactor error handling/validation to use a map return structure Was previously using a tuple structure. Now changed to use a {:result result :error error} structure. Made a errors namespace to house the do-or-error function. * Update password encryption to remove manual salting, bcrypt already does this Updated gen-new-user-map in user.clj to remove manual salting procedure Removed static salt from config.edn Removed get-static-salt fn from config.clj Updated 001-users.up.sql to remove dynamic_salt column from users table * Fix postgres timestamp error by requiring next.jdbc.date-time * Refactor to use component libary: add server component Started incremental refactor to use the component library. Implemented a component system map with a server component. Will add more components in future commits. * Refactor to use component library: add db component Added a db component to the component system map. db component is injected into the make-app function, and eventually used for db queries. * Add ring/ring-mock dependency * Add local test port number to config file * Remove ragtime.core dependency and edit comments * Add fn to get local test port from config file * Improve docstring for fn do-or-error and add comments * Change run-migrations and rollback fns to take dbspec as an argument Will improve these further in a future commit. * Add comments * Add a user-exists? fn * Improve comment to explain handler level validation * Add docstrings * Change jt/local-time -> jt/instant for health check * Modify delete-user successful response message * Modify namespace aliases * Modify namespace alias * Edit comments and explain model layer validation * Initialize fixture namespace with test-system and test-fixture for running tests * Add unit tests with stub fns to test handler layer functions Moved into handler folder to mimic project structure. Will add integration tests in a future commit * Add units tests with stub fns to test model layer user functions Will add integration tests in a future commit * Add integration tests for db layer user functions Will add tests for query results in a future commmit * Update readme to remove misleading info Will add more info in a future commit. * Add dependencies * Initialize app_test.clj with end-end health check test * Add comment about improving fixtures * Improve parameter names for new-user? and user-exists? functions * Add helper function get-time-instant which calls jt/instant * Improve db layer tests * Improve model.user layer tests Added integration tests and removed stubs where not necessary * Improve handler layer tests Add integration tests and remove stubs where not necessary * Initialize db/utils.clj with database health-check * Modify health-check endpoint to also test for db status This makes the health-check endpoint a more comprehensive app status check, and is nice to use for an end->end test. Modified routes.clj, handler.clj and handler_test.clj for this change. * Update .gitignore * Remove and cleanup comments * Improve get config fns * Update implementation of user-exists? and new-user? fns * Update to return correct status codes for errors Created an error map in the chaat.handler.errors namespace which contains status codes for common errors. Created a send-response helper fn. Also updated tests. * Simplify fn names: gen-new-user-map -> gen-new-user and gen-config-map -> gen-config * Removing empty deftest blocks for fns which do not need testing * Remove dead code relating to user display-picture implementation * Update fn name end-end-test -> health-check-test
All tasks were completed. PR reviewed and merged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: