This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from NavigoLearn/master
Pushing V2 to production branch
- Loading branch information
Showing
105 changed files
with
6,489 additions
and
10,996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# ESLint is a tool for identifying and reporting on patterns | ||
# found in ECMAScript/JavaScript code. | ||
# More details at https://github.com/eslint/eslint | ||
# and https://eslint.org | ||
|
||
name: ESLint | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "master" ] | ||
schedule: | ||
- cron: '18 4 * * 6' | ||
|
||
jobs: | ||
eslint: | ||
name: Run eslint scanning | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # required to comit eslint fix | ||
security-events: write | ||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install ESLint | ||
run: | | ||
npm install --save-dev [email protected] | ||
npm install --save-dev @microsoft/[email protected] | ||
- name: Run ESLint | ||
run: npx eslint . | ||
--config .eslintrc.json | ||
--ext .js,.jsx,.ts,.tsx | ||
--format @microsoft/eslint-formatter-sarif | ||
--output-file eslint-results.sarif | ||
continue-on-error: true | ||
|
||
- name: Upload analysis results to GitHub | ||
uses: github/codeql-action/upload-sarif@v2 | ||
with: | ||
sarif_file: eslint-results.sarif | ||
wait-for-processing: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: ESLint Fix on Push to Master | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
eslint-fix: | ||
name: Fix ESLint Issues | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install ESLint | ||
run: | | ||
npm install --save-dev [email protected] | ||
npm install --save-dev @microsoft/[email protected] | ||
- name: Run ESLint with --fix | ||
run: npx eslint . --config .eslintrc.json --ext .js,.jsx,.ts,.tsx --fix | ||
continue-on-error: true | ||
|
||
- name: Commit files | ||
run: | | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git commit -a -m "Fix ESLint issues" | ||
continue-on-error: true | ||
|
||
- name: Push changes | ||
uses: ad-m/github-push-action@29f05e01bb17e6f28228b47437e03a7b69e1f9ef | ||
with: | ||
branch: ${{ github.ref_name }} | ||
github_token: ${{ secrets.PAT }} | ||
continue-on-error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# Navigo Learn API [![CodeFactor](https://www.codefactor.io/repository/github/navigolearn/api/badge/master)](https://www.codefactor.io/repository/github/navigolearn/api/overview/master) | ||
# Navigo Learn API | ||
|
||
| Build Status | Badge | | ||
|:------------:|:--------------------------------------------------------------------------------------------------------:| | ||
| Production | ![Build Status](https://github.com/navigolearn/api/actions/workflows/test.yml/badge.svg?branch=prod) | | ||
| Master | ![Build Status](https://github.com/navigolearn/api/actions/workflows/test.yml/badge.svg?branch=master) | | ||
|
||
## ! This is a work in progress ! | ||
|
||
|
@@ -17,41 +22,71 @@ MariaDB. | |
|
||
Documentation for the api can be found [here](docs/paths/README.md). | ||
|
||
## Available Scripts | ||
|
||
### `npm run dev` | ||
|
||
Run the server in development mode. | ||
|
||
### `npm test` | ||
|
||
Run all unit-tests with hot-reloading. | ||
|
||
### `npm test -- --testFile="name of test file" (i.e. --testFile=Users).` | ||
|
||
Run a single unit-test. | ||
|
||
### `npm run test:no-reloading` | ||
|
||
Run all unit-tests without hot-reloading. | ||
|
||
### `npm run lint` | ||
|
||
Check for linting errors. | ||
|
||
### `npm run build` | ||
|
||
Build the project for production. | ||
|
||
### `npm start` | ||
|
||
Run the production build (Must be built first). | ||
|
||
### `npm start -- --env="name of env file" (default is production).` | ||
|
||
Run production build with a different env file. | ||
|
||
## Additional Notes | ||
|
||
- If `npm run dev` gives you issues with bcrypt on MacOS you may need to | ||
run: `npm rebuild bcrypt --build-from-source`. | ||
# Getting Started | ||
|
||
## Prerequisites | ||
|
||
- [Node.js](https://nodejs.org/en/) - v16 or higher | ||
- [MariaDB](https://mariadb.org/) - v10.6 or higher | ||
- [Git](https://git-scm.com/) - v2.32 or higher | ||
|
||
## Installation | ||
|
||
1. Clone the repo | ||
```sh | ||
git clone [email protected]:NavigoLearn/API.git | ||
``` | ||
|
||
2. Install NPM packages | ||
```sh | ||
npm install | ||
``` | ||
|
||
3. Create a MariaDB database | ||
```sh | ||
CREATE DATABASE navigo_learn; | ||
USE navigo_learn; | ||
CREATE USER 'navigo_learn'@'localhost' IDENTIFIED BY 'password'; | ||
GRANT ALL PRIVILEGES ON navigo_learn.* TO 'navigo_learn'@'localhost'; | ||
``` | ||
|
||
4. Rename the env.example folder to env and fill in the values for | ||
development.env | ||
|
||
5. Run tests to make sure everything works | ||
```sh | ||
npm test | ||
``` | ||
|
||
6. Run the server | ||
```sh | ||
npm run dev | ||
``` | ||
|
||
## Structure of the Project | ||
|
||
The project is split into 4 main folders: | ||
|
||
- `src` - Contains all the source code for the project. | ||
- `spec` - Contains all the unit-tests for the project. | ||
- `docs` - Contains all the documentation for the project. | ||
- `env` - Contains all the environment files for the project. (rename the | ||
env.example folder to env to use it) | ||
|
||
### `src` | ||
|
||
The `src` folder is split into multiple main folders: | ||
|
||
- `constants` - Contains constants used in the project. (HTTP status codes, env | ||
variables, etc.) | ||
- `controllers` - Contains the controllers of the project. | ||
- `middleware` - Contains middleware used in the project. (session, etc.) | ||
- `models` - Contains the data models for the project. (Roadmap, User, etc.) | ||
- `routes` - Contains the routers pointing to controllers. (auth, users, etc.) | ||
- `sql` - Contains sql files used in the project. (create tables, metrics, etc.) | ||
- `utils` - Contains utility functions used in the project. (databaseDriver, | ||
etc.) | ||
- `validators` - Contains the validators used in the project. (user, roadmap, | ||
etc.) | ||
- `index.ts` - The entry point. | ||
- `server.ts` - The server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
### `npm run dev` | ||
|
||
Run the server in development mode. | ||
|
||
### `npm test` | ||
|
||
Run all unit-tests with hot-reloading. | ||
|
||
### `npm test -- --testFile="name of test file" (i.e. --testFile=Users).` | ||
|
||
Run a single unit-test. | ||
|
||
### `npm run test:no-reloading` | ||
|
||
Run all unit-tests without hot-reloading. | ||
|
||
### `npm run lint` | ||
|
||
Check for linting errors. | ||
|
||
### `npm run build` | ||
|
||
Build the project for production. | ||
|
||
### `npm start` | ||
|
||
Run the production build (Must be built first). | ||
|
||
### `npm start -- --env="name of env file" (default is production).` | ||
|
||
Run production build with a different env file. | ||
|
||
## Additional Notes | ||
|
||
- If `npm run dev` gives you issues with bcrypt on MacOS you may need to | ||
run: `npm rebuild bcrypt --build-from-source`. |
Submodule env
updated
from fcef61 to a9f299
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Environment ## | ||
NODE_ENV=development | ||
|
||
## Server ## | ||
PORT=3001 | ||
HOST=localhost | ||
|
||
## Setup jet-logger ## | ||
JET_LOGGER_MODE=CONSOLE | ||
JET_LOGGER_FILEPATH=jet-logger.log | ||
JET_LOGGER_TIMESTAMP=TRUE | ||
JET_LOGGER_FORMAT=LINE | ||
|
||
## Authentication ## | ||
COOKIE_DOMAIN=localhost | ||
COOKIE_PATH=/ | ||
SECURE_COOKIE=false | ||
COOKIE_SECRET=xxxxxxxxxxxxxx | ||
# expires in 3 days | ||
COOKIE_EXP=259200000 | ||
|
||
## Database Authentication | ||
MARIADB_HOST=localhost | ||
MARIADB_USER=xxxxxxx | ||
MARIADB_PASSWORD=xxxxxx | ||
MARIADB_DATABASE=xxxxxxx | ||
|
||
## Google Authentication | ||
GOOGLE_CLIENT_ID=xxxxxxxxx | ||
GOOGLE_CLIENT_SECRET=xxxxxxxxx | ||
GOOGLE_REDIRECT_URI=xxxxxxxxxxx | ||
|
||
## GITHUB Authentication | ||
GITHUB_CLIENT_ID=xxxxxxxxxxx | ||
GITHUB_CLIENT_SECRET=xxxxxxxxxxxx | ||
GITHUB_REDIRECT_URI=xxxxxxxxxxxxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Environment ## | ||
NODE_ENV=production | ||
|
||
## Server ## | ||
PORT=3001 | ||
HOST=localhost | ||
|
||
## Setup jet-logger ## | ||
JET_LOGGER_MODE=CONSOLE | ||
JET_LOGGER_FILEPATH=jet-logger.log | ||
JET_LOGGER_TIMESTAMP=TRUE | ||
JET_LOGGER_FORMAT=LINE | ||
|
||
## Authentication ## | ||
COOKIE_DOMAIN=localhost | ||
COOKIE_PATH=/ | ||
SECURE_COOKIE=false | ||
COOKIE_SECRET=xxxxxxxxxxxxxx | ||
# expires in 3 days | ||
COOKIE_EXP=259200000 | ||
|
||
## Database Authentication | ||
MARIADB_HOST=localhost | ||
MARIADB_USER=xxxxxxx | ||
MARIADB_PASSWORD=xxxxxx | ||
MARIADB_DATABASE=xxxxxxx | ||
|
||
## Google Authentication | ||
GOOGLE_CLIENT_ID=xxxxxxxxx | ||
GOOGLE_CLIENT_SECRET=xxxxxxxxx | ||
GOOGLE_REDIRECT_URI=xxxxxxxxxxx | ||
|
||
## GITHUB Authentication | ||
GITHUB_CLIENT_ID=xxxxxxxxxxx | ||
GITHUB_CLIENT_SECRET=xxxxxxxxxxxx | ||
GITHUB_REDIRECT_URI=xxxxxxxxxxxxxx |
Oops, something went wrong.