Skip to content
Closed
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7af337e
Update package.json: Correct errors and migrate from yarn to npm
mugishaj092 May 13, 2024
fae16d4
Run Codeclimate and test coverage
GabrielDushime May 13, 2024
6614aca
Adding .env
GabrielDushime May 15, 2024
9f3f4c9
Add HoundCI badge to README
GabrielDushime May 15, 2024
7dd95dc
Removed folder from repository
GabrielDushime May 17, 2024
72ae77a
Removing Comment From ReadMe
GabrielDushime May 17, 2024
160962a
configuring pg and sequelize
mutsinziisaac May 13, 2024
57d0367
moving model directory form root to src
mutsinziisaac May 13, 2024
2d4792e
Configured Docker Compose to run two services: an Express server and …
mugishaj092 May 15, 2024
e9ef843
Pull request tempate
mugishaj092 May 16, 2024
b8a12e5
Integrating CircleCi With ReadMe
GabrielDushime May 20, 2024
a6cbeec
User registration endpoint
mugishaj092 May 17, 2024
f946ccc
add test and coverage badge
jamesndekezi May 20, 2024
3e3d199
swagger jsodc setup merge conflicts fixed
kennyg37 May 20, 2024
fdfe7ed
Resolving Conflicts
GabrielDushime May 20, 2024
d40aa83
Integrate HoundCI with badge attached to readme
GabrielDushime May 23, 2024
6f86c0d
Configuring-Codeclimate-Adding-Test_coverage
GabrielDushime May 23, 2024
2074589
Adding Maintainability badge
GabrielDushime May 23, 2024
e954184
send verification email after signing up
mutsinziisaac May 22, 2024
08c1cb5
make the sending email function reusable
mutsinziisaac May 23, 2024
f76405b
Adding npm install
GabrielDushime May 23, 2024
0fc0ce7
SetUp ESlint and pre-commit hooks configs
SHYAKA-Aime May 14, 2024
617aa93
resolving conflicts in Package.json
SHYAKA-Aime May 17, 2024
e80c9ce
added ESLINT config guide
SHYAKA-Aime May 20, 2024
6f28b3b
nyc jest --coverage
GabrielDushime May 27, 2024
2c0fd84
nyc jest --coverage
GabrielDushime May 27, 2024
4d3559f
Merge branch 'ft-testnyc-jest-coverage' of https://github.com/atlp-rw…
GabrielDushime May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
70 changes: 70 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: 2.1

orbs:
node: circleci/node@4.0.0

executors:
node-executor:
docker:
- image: circleci/node:16

jobs:
build:

executor:
name: node/default

executor: node-executor
environment:
CC_TEST_REPORTER_ID: b996f145a438f80141cfcc86bb35a2c212a2a24c394abee18da6add05eaaee7e
steps:
- checkout
# - node/install-packages
- run: npm install
- run:
name: Initialize Code Climate test reporter
command: cc-test-reporter before-build
- run:
name: Run Tests with Coverage
command: npm run test:coverage
- run:
name: Format Coverage Report
command: nyc report --reporter=text-lcov > coverage.lcov
- run:
name: Upload Coverage Report to Code Climate
command: |
cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.json coverage.lcov
cc-test-reporter upload-coverage
- run:
name: Initialize Code Climate test reporter
command: cc-test-reporter before-build
- run:
name: Run Tests with Coverage
command: npm run test:coverage
- run:
name: Format Coverage Report
command: nyc report --reporter=text-lcov > coverage.lcov
- run:
name: Upload Coverage Report to Code Climate
command: |
cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.json coverage.lcov
cc-test-reporter upload-coverage

deploy:
docker:
- image: circleci/node:14.17
steps:
- checkout
- run:
name: Build Project
command: tsc

workflows:
version: 2
build_and_deploy:
jobs:
- build
- deploy:
requires:
- build

33 changes: 33 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

version: "2"
checks:
argument_count:
enabled: true
file_lines:
enabled: true
method_count:
enabled: true
return_count:
enabled: true

exclude_paths:
- "node_modules/**"
- "coverage/**"

engines:
eslint:
enabled: true
config:
extensions:
- .js
- .jsx

ratings:
paths:
- "**.js"
- "**.jsx"

test_reporter:
id: "cc-test-reporter"
coverage_file:
- "coverage/lcov.info"
26 changes: 21 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
PORT=
DEV_DATABASE_URL=
TEST_DATABASE_UR=
DATABASE_URL=
JWT_SECRET=
PORT =
JWT_SECRET =
DB_URL =

DEV_DB_NAME =
DEV_DB_USER =
DEV_DB_PASS =
DEV_DB_HOST =

TEST_DB_NAME =
TEST_DB_USER =
TEST_DB_PASS =
TEST_DB_HOST =

PRO_DB_NAME =
PRO_DB_USER =
PRO_DB_PASS =
PRO_DB_HOST =

EMAIL_USER =
EMAIL_PASS =
41 changes: 41 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"root": true,
"extends": "airbnb-base",
"env": {
"node": true,
"es6": true,
"mocha": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"one-var": 0,
"one-var-declaration-per-line": 0,
"new-cap": 0,
"consistent-return": 0,
"no-param-reassign": 0,
"comma-dangle": 0,
"curly": ["error", "multi-line"],
"import/no-unresolved": [2, { "commonjs": true }],
"no-shadow": ["error", { "allow": ["req", "res", "err"] }],
"valid-jsdoc": ["error", {
"requireReturn": true,
"requireReturnType": true,
"requireParamDescription": false,
"requireReturnDescription": true
}],
"require-jsdoc": ["error", {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}]
}
}
36 changes: 36 additions & 0 deletions .github/workflows/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: e-commerce-furebo-32-bn.

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Build app
run: npm run build

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

name: Test Coverage

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm run test

- name: Upload coverage to CodeClimate
env:
CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_REPO_TOKEN }}
run: |
npm install -g codeclimate-test-reporter
codeclimate-test-reporter < coverage/lcov.info
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/node_modules
.env
.env
/coverage
/dist
24 changes: 24 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Example .hound.yml for a Node.js, Express, Postgres, and React on our e-commerce project
eslint:
enabled: true
config_file: .eslintrc.json
ignore_file: .eslintignore

jscs:
enabled: true
config_file: .jscsrc

npm:
enabled: true

# React specific rules
react:
enabled: true
jsx_file_extensions:
- ".jsx"
- ".tsx"

# SQL linting
eslint_sql:
enabled: true
config_file: .eslintrc-sql.json
1 change: 1 addition & 0 deletions Conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ For specific files, we will be using dot notation with `element.action.ts`. For
- Services: `element.service.ts (Example: user.services.ts)`
- Routes: `element.route.ts (Example: user.route.ts)`
- Test: `element.test.ts(Example: user.test.ts)`
- Utils: `element.utils.ts(Example: password.utils.ts)`

### MODEL: FOR MODEL NAMING
- Model should be named as Entity in singular and start with a capital letter.
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:14

WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm","run","dev"]
27 changes: 27 additions & 0 deletions ESLINTCONFIG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
__Steps to Configure ESlint and Pre-commit Hooks in your local repository__<br>

Open Your Git bash and run the following commands<br>

1.```npx husky install ``` <br>
To add the .husky Directory

2.After that, navigate to the __.husky__ directory which has been Added and add this piece of code to the __pre-commit__ file:<br>

```
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Run ESLint with --fix option to format code
npx eslint --fix .

# Run tests
npm run test

```
<br>

3. ```chmod +x .husky/pre-commit``` <br>
To Make the pre-commit file executable


__note: The above commands has to be run in the Git Bash, not Powershell Terminal__
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@



[![Test Coverage](https://api.codeclimate.com/v1/badges/b8b4783a32fb76cb4953/test_coverage)](https://codeclimate.com/github/atlp-rwanda/e-commerce-furebo-32-bn/test_coverage)

[![Maintainability](https://api.codeclimate.com/v1/badges/b8b4783a32fb76cb4953/maintainability)](https://codeclimate.com/github/atlp-rwanda/e-commerce-furebo-32-bn/maintainability)
12 changes: 12 additions & 0 deletions __test__/home.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, test } from "@jest/globals"
import request from "supertest"
import app from "../app"


describe("Testing home route", () => {
test("should return 200 status code", async() => {
const response = await request(app).get("/")
expect(response.body.message).toBe("welcome to ATLP Backend APIs");
expect(response.statusCode).toBe(200)
})
})
15 changes: 15 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import express, { Request, Response } from "express";
import swaggerUi from 'swagger-ui-express';
import specs from './swagger.config';

const app = express();

app.use(express.json());

app.get('/', (_req: Request, res: Response) => {
return res.json({ message: "welcome to ATLP Backend APIs" });
});
// Swagger UI route
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));

export default app;
23 changes: 23 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"development": {
"username": "postgres",
"password": "1234",
"database": "data",
"host": "127.0.0.1",
"dialect": "postgres"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "postgres"
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "postgres"
}
}
Loading