Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit a1fa732

Browse files
authored
Merge pull request #63 from NavigoLearn/master
Master to prod
2 parents 9c88478 + 77ab5f9 commit a1fa732

112 files changed

Lines changed: 2717 additions & 695 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CODE_OF_CONDUCT.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# NavigoLearn Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the spirit of fostering an open and welcoming environment, we, as contributors and maintainers, pledge to make participation in our project and our community a harassment-free experience for everyone. This commitment applies regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
NavigoLearn is a community-driven and open-source project that aims to share knowledge and experiences in programming. Our goal is to create a supportive and inclusive space where everyone can freely share their love for learning and programming.
8+
9+
## Our Standards
10+
11+
Positive behavior contributions include:
12+
13+
* Using welcoming and inclusive language
14+
* Being respectful of differing viewpoints and experiences
15+
* Accepting constructive criticism graciously
16+
* Prioritizing the best interests of the community
17+
* Demonstrating empathy towards other community members
18+
19+
Unacceptable behaviors include:
20+
21+
* Use of sexualized language or imagery and unwelcome sexual attention or advances
22+
* Trolling, insulting/derogatory comments, and personal or political attacks
23+
* Public or private harassment
24+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
25+
* Conduct which could reasonably be considered inappropriate in a professional setting
26+
27+
## Our Responsibilities
28+
29+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate corrective action in response to any instances of unacceptable behavior.
30+
31+
Maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this code of conduct.
32+
33+
## Scope
34+
35+
This Code of Conduct applies within all project spaces, and also applies when an individual is representing the project or its community in public spaces. Examples of representing the project include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative online or offline.
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior can be reported to the project team at [navigolearn@gmail.com](mailto:navigolearn@gmail.com).
40+
41+
All complaints will be reviewed and investigated and will result in a response that is considered necessary and appropriate to the circumstances.
42+
43+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions imposed by other members of the project's leadership.
44+
45+
## Attribution
46+
47+
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Welcome Aboard, Contributor!
2+
3+
Hello! We are thrilled to see you here and greatly appreciate your interest in contributing to the NavigoLearn API. Here, we've set up a few guidelines to make the contribution process smooth sailing.
4+
5+
## Code of Conduct
6+
7+
First off, we ask all contributors to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). Please ensure you read and understand it before participating in our community.
8+
9+
## Prepare for Your Journey
10+
11+
If you're new to our codebase, we've got you covered. Refer to the setup guide provided in the [README.md](README.md) file. This will help you set up your local development environment and get you started on your journey with us.
12+
13+
## Set Sail for Contribution
14+
15+
1. **Fork the Repository** - Start by creating a fork of our repository to your account, then clone it to your local machine for direct access.
16+
17+
2. **Gear Up Your Development Environment** - Make a new branch for your amazing feature or perhaps that clever bug fix (try to name the branch something descriptive!).
18+
19+
3. **Chart Your Changes** - Now, you're all set to modify the necessary files to implement your magic. Make sure to follow any guidelines in the [Internal Documentation](docs/internal/README.md) and [API Reference](docs/api_reference/README.md) to ensure your changes are consistent with the rest of the codebase. Also, make sure to add any new files to the appropriate documentation files or ask for help regarding writing documentation.
20+
21+
4. **Test the Waters** - Make sure to test your changes. If you can, add tests that cover your changes.
22+
23+
5. **Submit a Pull Request** - You can now push your changes to your fork and submit a pull request to the `master` branch in our GitHub repository.
24+
25+
Kindly ensure your PR has a detailed summary of changes. Discuss the problem you're tackling, identify the solution you've come up with, and share a concise and illustrative rationale for your changes.
26+
27+
## Style Guidelines & Naming Conventions
28+
29+
Consistency is key, and a clean, uniform codebase is a joy to work with. For our TypeScript project, we use ESLint to enforce code standards and catch potential issues.
30+
31+
Api endpoints are named using kebab-case. For example, `GET /api/users/profile-picture` is a valid endpoint.
32+
33+
For functions, variables and SQL tables, we use camelCase. For example, `db.getWhere('roadmapLikes', 'userId', userId, 'roadmapId', roadmapId);` is valid.
34+
35+
### ESLint
36+
37+
Before you submit your pull request, ensure your changes pass ESLint without any errors. If any ESLint warnings remain, they should be few and justifiable with clear explanation. Make sure to include any explanation or justification for unresolved ESLint warnings in your pull request comments.
38+
39+
We recommend running `npm run lint`(/src) and `npm run lint:tests`(/spec) locally before pushing your changes. This will invoke ESLint and report any issues.
40+
41+
Thank you for helping us maintain a consistent and clean codebase!
42+
43+
## Release Shore Ahead
44+
45+
We typically cut loose new releases every few weeks. Rest assured, once your changes have merged, they'll find their rightful place in our next release.
46+
47+
Thank you for setting sail with us! Your contribution helps make NavigoLearn API the treasure it is.

README.md

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Navigo Learn API
1+
# NavigoLearn API
22

33
| Build Status | Badge |
44
|:------------:|:--------------------------------------------------------------------------------------------------------:|
@@ -20,14 +20,17 @@ MariaDB.
2020

2121
## Documentation
2222

23-
Documentation for the api can be found [here](docs/paths/README.md).
23+
- [API endpoint reference](./docs/api_reference/README.md)
24+
- [Internal documentation](./docs/internal/README.md)
25+
- [Contributing guidelines](./CONTRIBUTING.md)
26+
- [Code of conduct](./CODE_OF_CONDUCT.md)
2427

2528
# Getting Started
2629

2730
## Prerequisites
2831

29-
- [Node.js](https://nodejs.org/en/) - v16 or higher
30-
- [MariaDB](https://mariadb.org/) - v10.6 or higher
32+
- [Node.js](https://nodejs.org/en/) - v18 or higher
33+
- [MariaDB](https://mariadb.org/) - v10.11 or higher
3134
- [Git](https://git-scm.com/) - v2.32 or higher
3235

3336
## Installation
@@ -61,32 +64,4 @@ Documentation for the api can be found [here](docs/paths/README.md).
6164
6. Run the server
6265
```sh
6366
npm run dev
64-
```
65-
66-
## Structure of the Project
67-
68-
The project is split into 4 main folders:
69-
70-
- `src` - Contains all the source code for the project.
71-
- `spec` - Contains all the unit-tests for the project.
72-
- `docs` - Contains all the documentation for the project.
73-
- `env` - Contains all the environment files for the project. (rename the
74-
env.example folder to env to use it)
75-
76-
### `src`
77-
78-
The `src` folder is split into multiple main folders:
79-
80-
- `constants` - Contains constants used in the project. (HTTP status codes, env
81-
variables, etc.)
82-
- `controllers` - Contains the controllers of the project.
83-
- `middleware` - Contains middleware used in the project. (session, etc.)
84-
- `models` - Contains the data models for the project. (Roadmap, User, etc.)
85-
- `routes` - Contains the routers pointing to controllers. (auth, users, etc.)
86-
- `sql` - Contains sql files used in the project. (create tables, metrics, etc.)
87-
- `utils` - Contains utility functions used in the project. (databaseDriver,
88-
etc.)
89-
- `validators` - Contains the validators used in the project. (user, roadmap,
90-
etc.)
91-
- `index.ts` - The entry point.
92-
- `server.ts` - The server.
67+
```

docs/README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
# Navigo API Documentation
1+
# Documentation
22

3-
This is the documentation for the Navigo API. It is a RESTful API that allows
4-
you to create, read, update and delete data from the Navigo database.
3+
This directory contains detailed documentation for the NavigoLearn API.
54

65
## Table of Contents
76

8-
### 1. [Paths](paths/README.md)
7+
- [API Reference](./api_reference/README.md)
8+
- [Internal Architecture](./internal/README.md)
9+
- [Contribution Guidelines](../contributing.md)
10+
- [Code of Conduct](../CODE_OF_CONDUCT.md)
911

10-
### 2. [Types](types/README.md)
12+
## Overview
13+
14+
### API Reference
15+
16+
The [API Reference](./api_reference/README.md) directory provides a detailed reference of all API endpoints. For each endpoint, you will find its parameters and the response it delivers.
17+
18+
### Internal Architecture
19+
20+
The [Internal Architecture](./internal/README.md) directory is meant for developers who want to understand the codebase and possibly contribute. It includes detailed explanations about the API's models, controllers, routes, middleware, and other components.
21+
22+
### Contribution Guidelines
23+
24+
We love contributions from our community! The [Contribution Guidelines](../contributing.md) provide information on our code style guidelines and the Git workflow to be followed to contribute to this project.
25+
26+
### Code of Conduct
27+
28+
We expect all contributors to abide by our [Code of Conduct](../CODE_OF_CONDUCT.md). Please ensure you read and understand it before participating in our community.

docs/api_reference/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# API Reference
2+
3+
This directory provides detailed documentation of each endpoint in the NavigoLearn API.
4+
5+
6+
7+
## Overview
8+
9+
For each endpoint, we provide the following details:
10+
11+
- The HTTP method (GET, POST, PUT, DELETE)
12+
- Endpoint URL
13+
- Required parameters in the request
14+
- A short description of what the endpoint does
15+
- An example request
16+
- An example response
17+
18+
## Endpoints
19+
20+
- /api
21+
- /api/auth
22+
- [GET /api/auth/google-login](./auth/google-login.md)
23+
- [GET /api/auth/google-callback](./auth/google-callback.md)
24+
- [GET /api/auth/github-login](./auth/github-login.md)
25+
- [GET /api/auth/github-callback](./auth/github-callback.md)
26+
- [POST /api/auth/login](./auth/login.md)
27+
- [POST /api/auth/register](./auth/register.md)
28+
- [POST /api/auth/change-password](./auth/change-password.md)
29+
- [POST /api/auth/forgot-password](./auth/forgot-password.md) (Not Implemented - Not planned)
30+
- [DELETE /api/auth/logout](./auth/logout.md)
31+
- /api/search (formerly /api/explore)
32+
- [GET /api/search/roadmaps](./search/roadmaps.md)
33+
- [GET /api/search/feeling-lucky](./search/feeling-lucky.md)
34+
- ... More to be added
35+
- /api/roadmaps
36+
- [GET /api/roadmaps/:roadmapId](./roadmaps/get-roadmap.md)
37+
- [POST /api/roadmaps/create](./roadmaps/create-roadmap.md)
38+
- /api/roadmaps/:roadmapId
39+
- **Update roadmap data**
40+
- [POST /api/roadmaps/:roadmapId/](./roadmaps/update-roadmap.md)
41+
- [POST /api/roadmaps/:roadmapId/about](./roadmaps/update-roadmap-about.md)
42+
- [POST /api/roadmaps/:roadmapId/name](./roadmaps/update-roadmap-name.md)
43+
- [POST /api/roadmaps/:roadmapId/description](./roadmaps/update-roadmap-description.md)
44+
- [POST /api/roadmaps/:roadmapId/topics](./roadmaps/update-roadmap-topic.md)
45+
- [POST /api/roadmaps/:roadmapId/draft](./roadmaps/update-roadmap-draft.md)
46+
- [POST /api/roadmaps/:roadmapId/version](./roadmaps/update-roadmap-version.md)
47+
- [POST /api/roadmaps/:roadmapId/data](./roadmaps/update-roadmap-data.md)
48+
- [POST /api/roadmaps/:roadmapId/misc-data](./roadmaps/update-roadmap-misc-data.md)
49+
- **Interact with the roadmap**
50+
- [GET /api/roadmaps/:roadmapId/like](./roadmaps/like-roadmap.md)
51+
- [GET /api/roadmaps/:roadmapId/dislike](./roadmaps/unlike-roadmap.md)
52+
- [GET /api/roadmaps/:roadmapId/progress](./roadmaps/get-roadmap-progress.md)
53+
- [POST /api/roadmaps/:roadmapId/progress](./roadmaps/update-roadmap-progress.md)
54+
- [DELETE /api/roadmaps/:roadmapId/{like,dislike}](./roadmaps/delete-roadmap-like.md)
55+
- [DELETE /api/roadmaps/:roadmapId](./roadmaps/delete-roadmap.md)
56+
- /api/users
57+
- [GET /api/users/:userId?](./users/get-user.md)
58+
- [GET /api/users/:userId/mini](./users/get-user-mini.md)
59+
- [GET /api/users/:userId/roadmaps](./users/get-user-roadmaps.md)
60+
- [GET /api/users/:userId/follow](./users/follow-user.md)
61+
- [DELETE /api/users/:userId/follow](./users/unfollow-user.md)
62+
- [POST /api/users/](./users/update-user.md)
63+
- [POST /api/users/name](./users/update-user-name.md)
64+
- [POST /api/users/profile-picture](./users/update-user-profile-picture.md) (Not Implemented - Not plan)
65+
- [POST /api/users/bio](./users/update-user-bio.md)
66+
- [POST /api/users/quote](./users/update-user-quote.md)
67+
- [POST /api/users/website-url](./users/update-user-website-url.md)
68+
- [POST /api/users/github-url](./users/update-user-github-url.md) (To be added)
69+
- [DELETE /api/users/:userId](./users/delete-user.md)
70+
71+
## Responses
72+
73+
All responses are in JSON format and have the keys `success` and `message`. The `success` key is a boolean that indicates whether the request was successful or not. The `message` key is a string that contains a message about the request. If the request was successful, the `message` key will contain a confirmation message. If the request was unsuccessful, the `message` key will contain an error message.
74+
75+
Additionally, some responses will contain a `data` key. The `data` key will contain the data requested by the user. For example, if the user requests a roadmap, the `data` key will contain the roadmap data.
76+
77+
Also, some responses will contain a `total` key. The `total` key will contain the total number of items that match the response `data` array. For example, if the user requests a list of roadmaps, the `total` key will contain the total number of roadmaps that match the request.
78+
79+
**Each response file above contains an example response.**
80+
81+
## Note
82+
83+
Please note that this API reference is a work in progress and will continue to grow as new endpoints are added to the NavigoLearn API.
84+
85+
And some might change requirements or functionality as the project evolves.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# POST /api/auth/change-password
2+
3+
## Description
4+
5+
This endpoint is used to change the password of a user.
6+
7+
## Request
8+
9+
### Parameters
10+
11+
None
12+
13+
### Body
14+
15+
```json
16+
{
17+
"password": "string",
18+
"newPassword": "string"
19+
}
20+
```
21+
22+
### Headers
23+
24+
- 'cookie': 'token=...' (Must be valid)
25+
26+
## Response
27+
28+
```json
29+
{
30+
"success": true,
31+
"message": "Password changed successfully"
32+
}
33+
```
34+
35+
### Response Codes
36+
37+
Example:
38+
39+
| Code | Description |
40+
|------|------------------------|
41+
| 200 | Success |
42+
| 400 | Bad Request. |
43+
| 401 | Unauthorized. |
44+
| 429 | Too Many Requests |
45+
| 500 | Internal Server Error. |
46+
47+
### Cookies
48+
49+
None
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Not Implemented - Not planned
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# GET /api/auth/github-callback
2+
3+
## Description
4+
5+
This endpoint is used as a callback URL for GitHub OAuth2.0 authentication. It is called by GitHub after the user has successfully authenticated with GitHub.
6+
7+
## Request
8+
9+
### Parameters
10+
11+
See [GitHub OAuth2.0 documentation](https://docs.github.com/en/developers/apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github) for more information.
12+
13+
- `code`: The authorization code returned by GitHub after the user has successfully authenticated with GitHub.
14+
15+
### Body
16+
17+
None
18+
19+
### Headers
20+
21+
None
22+
23+
## Response
24+
25+
```json
26+
{
27+
"success": true,
28+
"message": "Login successful"
29+
}
30+
```
31+
32+
### Response Codes
33+
34+
Example:
35+
36+
| Code | Description |
37+
|------|------------------------|
38+
| 200 | Success |
39+
| 201 | Created |
40+
| 400 | Bad Request |
41+
| 500 | Internal Server Error. |
42+
43+
### Cookies
44+
45+
- `token` (optional): The JWT token that is used to authenticate the user. This cookie is only set if the user successfully authenticated with GitHub.

0 commit comments

Comments
 (0)