This is the backend of the Attendex app.
- Clone repo
npm i
to install dependencies- Fill up .env file with database password, and secret keys
npm run dev
to run the server with nodemon
- Node.js (Express)
- mysql2
- MySQL database
- JsonWebToken
-
authentication
table- contains userID and passwords of all accounts
- primary key is
userID
-
attendancebook
table- meant to represent a group of sheets, for example, a module has 13 lessons over 13 weeks, each lesson would be 1 sheet while the collection of 13 sheets is called an attendance book
- contains userID that this book belongs to, name of book, bookID
- primary key is
bookID
- foreign key
userID
referencesuserID
fromauthentication
tables
-
attendancesheet
table- meant to represent 1 date of the attendance book
- contains sheetID, bookID that this sheet belongs to, and the date
- primary key is
sheetID
- foreign key is
bookID
which referencesbookID
fromattendancebook
-
members
table- meant to represent the list of members that a book would contain, for example, a module could have 100 students taking it and all 100 students will have to turn up for each individual lesson (sheet)
- contains bookID, name of member, and memberID
- primary key is
memberID
- foreign key is
bookID
which referencebookID
fromattendancebook
-
memberattendance
table- meant to represent a single dates attendance list, much like a checklist to check if attendees are present for 1 session
- contains sheetID that this date belongs to, memberID that this entry belongs to and whether the member in this sheet attended
- first foreign key is
memberID
which referencememberID
frommembers
table - second foreign key is
fk_sheetID
which referencesheetID
fromattendancesheet
table
-
Accounts
- sign up
- path: POST /signup
- body: password
- login
- path: POST /login
- body: userid, password
- errors: 403 (wrong userid / password)
- delete account
- path: DELETE /deleteaccount
- sign up
-
Attendance Book
- add book
- path: POST /addbook
- body: bookname
- error: 409 (book name already exists)
- delete book
- path: DELETE /deletebook
- body: bookid
- get books
- path: GET /getbook
- update book name
- path: PUT /updatebookname
- body: bookid, bookname
- error: 409 (book name already exists)
- add book
-
Attendance Sheet
- add sheet
- path: POST /addsheet
- body: bookid, date
- error : 409 (sheet already exist)
- delete sheet
- path: DELETE /deletesheet
- body: sheetid
- get sheet
- path: GET /getsheet
- body: sheetid
- get date
- path: GET /getdate
- body: bookid
- add sheet
-
Members
- add member
- path: POST /addmember
- body: bookid, name
- error: 409 (member name already exists)
- delete member
- path: DELETE /deletemember
- body: memberid
- get members
- path: GET /getmember
- body: bookid
- update member name
- path: PUT /updatemembername
- body: name, memberid
- error: 409 (member name already exists)
- add member
-
Member Attendance
- update member attendance
- path: PUT /updatememberattendance
- body: sheetid, memberid, attended
- update member attendance
All API calls has errors:
- HTTP status code 400 (Bad Error) if input formats are wrong
- HTTP status code 401 (Unauthorised) if JWT token expired or unverified