File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
chapter-05-the-dependency-inversion-principle/refactor Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1- function userProvider ( connection ) {
1+ /**
2+ * @implements {UserProviderInterface}
3+ */
4+ function mysqlUserProvider ( connection ) {
25 function findUser ( username ) {
36 return connection . fetchAssoc ( 'SELECT * FROM users WHERE username = ?' , [
47 username ,
@@ -10,4 +13,4 @@ function userProvider(connection) {
1013 } ;
1114}
1215
13- module . exports = userProvider ;
16+ module . exports = mysqlUserProvider ;
Original file line number Diff line number Diff line change 1+ /**
2+ * In order to improve the understanding of this code, this file it is supposing to implement the following interface:
3+ *
4+ * interface UserProviderInterface {
5+ * function findUser(username);
6+ * }
7+ *
8+ * Quack Quack Quack 🦆 typing :D
9+ */
10+
11+ /**
12+ * @param {UserProviderInterface } userProvider
13+ */
114function authentication ( userProvider ) {
215 function checkCredentials ( username , password ) {
316 const user = userProvider . findUser ( username ) ;
You can’t perform that action at this time.
0 commit comments