This will be where I update my solutions for BED Practical 6 onwards :D
File structure:
mysql-api/
┣ src/
┃ ┣ api/
┃ ┃ ┣ controller/
┃ ┃ ┃ ┣ app.js
┃ ┃ ┃ ┗ userController.js
┃ ┃ ┣ middleware/
┃ ┃ ┃ ┣ async.js
┃ ┃ ┃ ┗ errHandler.js
┃ ┃ ┣ model/
┃ ┃ ┃ ┗ user.js
┃ ┃ ┗ routes/
┃ ┃ ┣ friendRouter.js
┃ ┃ ┗ userRouter.js
┃ ┣ config/
┃ ┃ ┣ .env
┃ ┃ ┗ dbConfig.js
┃ ┗ server.js
┣ .gitignore
┣ package.json
┣ README.md
┗ yarn.lock
- Add PUT methods for /user/:userid enpoint to edit/update data
- Add routes for /friends endpoint
- Reformat code to use async await
Note: A database has to be created beforehand to use this.
- Clone repo:
git clone https://github.com/timothyckl/mysql-api
- Install all packages:
yarn install
# or
npm install
- Run server.js:
yarn start
# or
npm start