- Description
- Installation Instructions
- Usage and Screenshots
- Technologies Used
- Dependencies and Credits
- Project Structure
This is the RESTful API created for my messenger app as a part of The Odin Project curriculum (Full Stack JavaScript track). It is built using Node.js and Express with a PostgreSQL database managed using Prisma ORM.
- Clone or fork this repo
- cd into the project root directory (where the README.md file is located)
- Run the following in your terminal
-
npm init -y npm install @prisma/client @prisma/extension-accelerate bcryptjs npm install cors dotenv express npm install express-validator jsonwebtoken pg npm install @types/node jest prisma --save-dev npm install supertest tsx typescript --save-dev
-
- Create a .env file
-
NODE_ENV=development TEST_DATABASE_URL="your_local_test_database_url" DATABASE_URL="your_local_database_url" SECRET_KEY="your_secret_key" PORT=3000 (or any 4 digit even integer)
-
-
npm run dev
^+cwill end the process
- After making updates to ./src/queries.ts you'll want to run this to recompile queries.js
-
npx tsc
-
The API can be used by using the endpoints listed below.
- User Routes
- Friend Routes
- Message Routes
Route Notes
- Uses CORS to verify that the domain requesting access is valid
- Routes are fully tested
- @prisma/extension-accelerate
- @prisma/client
- @types/node
- bcryptjs
- cors
- dotenv
- express-validator
- jsonwebtoken
- pg
- supertest
- tsx
├──controllers/ # Controller files
├──db/ # Compiled queries.js file located here
├──generated/ # Generated Prisma files
├──prisma/ # Prisma models and migrations
├──routes/ # Router files
├──src/ # Raw uncompiled queries.ts file located here
└──test/ # Test files located hereFootnotes
-
Expects { name, password, confirmPassword }. Returns { id, name, hash }. ↩
-
Expects { name, password }. Returns { token } property which contains the JSON Web Token for the user. ↩
-
Requires auth header. Expects { name, password }. Sends a status code 200. ↩
-
Requires auth header. Expects { name }. Returns status 200 and { message: "New friendship with name added!" }. ↩
-
Expects only the user's id in the URL. Returns an array of user objects (see note 1 above). ↩
-
Requires auth header. Expects { name }. Returns { id, userAId, userBId } for the deleted friendship. ↩
-
Requires auth header. Expects { message }. Returns { id, senderId, receiverId, messageBody }. ↩
-
Requires auth header. Expects only the friend's id in the URL. Returns an array of message objects (see note 7 above). ↩
-
Requires auth header. Expects only the message id in the URL. Returns message object (see note 7 above). ↩