Usage - SeattleColleges/nsc-events-nestjs GitHub Wiki
Usage
Starting the Application
After installation and configuration, start the application with the following command:
npm run start:dev
Your application should now be running at http://localhost:3000.
API Endpoints
Activity Controller (/events)
- Get All Activities: GET api/events
- Find Activity by ID: GET api/events/find/:id
- Attend an Event: POST api/events/attend/:id
- Add New Event: POST api/events/new
- Update Activity by ID: PUT api/events/update/:id
- Delete Activity by ID: DELETE /events/remove/:id
User Controller (/user)
- Get All Users: GET api/users
- Get User by ID: GET api/users/:id
- Get User by Email: GET api/users/email/:email
- Update User: PATCH api/users/update/:id
- Delete User: DELETE api/users/remove/:id
Auth Controller (/auth)
- Login: POST api/auth/login
- Sign-up: POST api/auth/signup
- Forgot Password: POST api/auth/forgot-password
- Refresh Token: POST api/auth/refresh-token (TBD)
- Logout: POST api/auth/logout (TBD)
To authenticate, use the api/auth/login endpoint to receive a JWT token. Include this token in the Authorization header for subsequent requests. Learn more at https://jwt.io/
Examples Using Postman
Sign-up
- Open Postman.
- Set the request type to POST.
- Enter the URL
http://localhost:3000/api/auth/signup. - Under Body, choose raw and JSON (application/json).
- Enter the JSON data, e.g., {"name": "new_username", "email": "new_email", "password": "new_password", "role": "user_role"}.
- Send the request.
Login
- Open Postman.
- Set the request type to POST.
- Enter the URL
http://localhost:3000/api/auth/login. - Under Body, choose raw and JSON (application/json).
- Enter the JSON data, e.g., {"email": "your_email", "password": "your_password"}.
- Send the request.
Fetching All Activities
- Open Postman.
- Set the request type to GET.
- Enter the URL
http://localhost:3000/api/events. - This route is unguarded so it doesn't require AUTHORIZATION in the header
- Send the request.
Creating a New Activity
- Open Postman.
- Set the request type to POST.
- Enter the URL
http://localhost:3000/api/events/new. - Under Headers, set Authorization to Bearer YOUR_JWT_TOKEN.
- Under Body, choose raw and JSON (application/json).
- Enter the JSON data, e.g.,
{
"eventCreatorId": "64f6b79583e4cdccda1a02b2",
"eventTitle": "Sample Event",
"eventDescription": "description",
"eventCategory": "Tech",
"eventDate": "2023-08-15",
"eventStartTime": "10:00 AM",
"eventEndTime": "1:00 PM",
"eventLocation": "123 Main Street, City",
"eventCoverPhoto": "https://ourCloudStorage.com/sample-event.photo.png",
"eventHost": "Sample Organization",
"eventWebsite": "https://example.com/sample-event",
"eventRegistration": "Register at https://example.com/registration",
"eventCapacity": "100",
"eventCost": "$10",
"eventTags": ["Tech", "Conference", "Networking"],
"eventSchedule": "10:00 AM - Registration\n11:00 AM - Keynote\n12:00 PM - Lunch\n2:00 PM - Workshops\n4:00 PM - Closing Remarks",
"eventSpeakers": ["John Doe", "Jane Smith"],
"eventPrerequisites": "None",
"eventCancellationPolicy": "Full refund if canceled at least 7 days before the event.",
"eventContact": "[email protected]",
"eventSocialMedia": {
"facebook": "https://www.facebook.com/sampleevent",
"twitter": "https://twitter.com/sampleevent",
"instagram": "https://www.instagram.com/sampleevent",
"hashtag": "#SampleEvent2023"
},
"eventPrivacy": null,
"eventAccessibility": "Wheelchair accessible venue."
}
- Send the request.