Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:atlp-rwanda/e-commerce-ninjas-bn…
Browse files Browse the repository at this point in the history
… into fixes
  • Loading branch information
Aime-Patrick committed Aug 20, 2024
2 parents 4e58074 + 88c7093 commit 4721862
Show file tree
Hide file tree
Showing 25 changed files with 797 additions and 282 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ DOCKER_DATABASE_PASSWORD=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

PASSWORD_EXPIRATION_DAYS=
ADMIN_EMAIL=
8 changes: 4 additions & 4 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"check-coverage": true,
"lines": 80,
"statements": 80,
"functions": 70,
"branches": 70
"lines": 60,
"statements": 60,
"functions": 60,
"branches": 60
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "e-commerce-ninjas",
"version": "1.0.0",
"description": "Backend repo for team projecct",
"description": "Backend repo for team project",
"main": "index.js",
"lint-staged": {
"*.{js,ts,tsx}": "eslint --fix"
Expand Down Expand Up @@ -30,10 +30,10 @@
"postinstall": "husky install"
},
"nyc": {
"lines": 70,
"statements": 70,
"functions": 70,
"branches": 70,
"lines": 60,
"statements": 60,
"functions": 60,
"branches": 60,
"extends": "@istanbuljs/nyc-config-typescript",
"include": [
"src/**/!(*.test.*).[tj]s?(x)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
defaultValue: false
},
bankAccount: {
type: DataTypes.STRING(16),
type: DataTypes.STRING(128),
allowNull: true
},
bankName: {
Expand Down
38 changes: 38 additions & 0 deletions src/databases/migrations/20240812080129-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import { QueryInterface, DataTypes } from "sequelize";

export default {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("settings", {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
allowNull: false,
primaryKey: true
},
key: {
type: DataTypes.STRING(128),
allowNull: false,
unique: true
},
value: {
type: DataTypes.STRING(255),
allowNull: false
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
}
});
},

down: async (queryInterface: QueryInterface) => {
await queryInterface.dropTable("settings");
}
};
3 changes: 2 additions & 1 deletion src/databases/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ProductReviews from "./productReviews";
import wishListProducts from "./wishListProducts";
import SellerProfile from "./sellerProfile";
import Addresses from "./addresses";
import Settings from "./settings";
import PaymentMethods from "./paymentMethods";
import TermsAndConditions from "./termsAndCodition";

Expand All @@ -30,13 +31,13 @@ const db = {
wishListProducts,
SellerProfile,
Addresses,
Settings,
PaymentMethods,
TermsAndConditions
};

Object.values(db).forEach(model => {
if (model.associate) {
// @ts-expect-error: Model association method expects a different type signature
model.associate(db);
}
});
Expand Down
10 changes: 10 additions & 0 deletions src/databases/models/paymentMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ PaymentMethods.init(
type: DataTypes.STRING,
allowNull: true,
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
}
},
{
sequelize: sequelizeConnection,
Expand Down
61 changes: 61 additions & 0 deletions src/databases/models/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* eslint-disable */
import { Model, DataTypes } from "sequelize";
import sequelizeConnection from "../config/db.config";

export interface SettingsAttributes {
id: string;
key: string;
value: string;
createdAt?: Date;
updatedAt?: Date;
}

class Settings extends Model<SettingsAttributes> implements SettingsAttributes {
declare id: string;
declare key: string;
declare value: string;
declare createdAt?: Date;
declare updatedAt?: Date;

static associate(models: any) {
}
}

Settings.init(
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
key: {
type: DataTypes.STRING(128),
allowNull: false,
unique: true,
},
value: {
type: DataTypes.STRING(255),
allowNull: false,
},
createdAt: {
field: "createdAt",
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
updatedAt: {
field: "updatedAt",
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
},
},
{
sequelize: sequelizeConnection,
tableName: "settings",
timestamps: true,
modelName: "Settings",
}
);

export default Settings;
21 changes: 19 additions & 2 deletions src/databases/seeders/20240601224834-shops.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryInterface } from "sequelize";
import { shopFourId, shopOneId, shopThreeId, shopTwoId, userFourId, userFourTeenId, userSevenId, userSixId } from "../../types/uuid";
import { shopFiveId, shopFourId, shopOneId, shopSixId, shopThreeId, shopTwoId, userFiveId, userFiveTeenId, userFourId, userFourTeenId, userSevenId, userSixId } from "../../types/uuid";

const shopOne = {
id: shopOneId,
Expand Down Expand Up @@ -35,9 +35,26 @@ const shopFour = {
createdAt: new Date(),
updatedAt: new Date()
}
const shopFive = {
id: shopFiveId,
name: "Shop 509",
userId: userFiveId,
description: "Selling",
createdAt: new Date(),
updatedAt: new Date()
}
const shopSix = {
id: shopSixId,
name: "electronics Shop 509",
userId: userFiveTeenId,
description: "Selling",
createdAt: new Date(),
updatedAt: new Date()
}


export const up = async (queryInterface: QueryInterface) => {
await queryInterface.bulkInsert("shops", [shopOne, shopTwo,shopThree,shopFour]);
await queryInterface.bulkInsert("shops", [shopOne, shopTwo,shopThree,shopFour, shopFive, shopSix]);
};

export const down = async (queryInterface: QueryInterface) => {
Expand Down
72 changes: 72 additions & 0 deletions src/databases/seeders/20240625053833-paymentMethods.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { QueryInterface } from "sequelize";
import { paymentSixId, userFiveTeenId, paymentFiveId, userFourTeenId, paymentFourId, userSevenId, paymentThreeId, userSixId, paymentTwoId, userFiveId, paymentOneId, userFourId } from "../../types/uuid";

module.exports = {
async up(queryInterface: QueryInterface) {
await queryInterface.bulkInsert("paymentMethods", [
{
id:paymentOneId,
userId:userFourId,
bankPayment: true,
mobilePayment: false,
bankAccount: "2345r678908765432",
bankName: "Equity",
createdAt: new Date(),
updatedAt: new Date()
},
{
id:paymentTwoId,
userId:userFiveId,
bankPayment: true,
mobilePayment: false,
bankAccount: "2345r678908765432",
bankName: "Equity",
createdAt: new Date(),
updatedAt: new Date()
},
{
id:paymentThreeId,
userId:userSixId,
bankPayment: true,
mobilePayment: false,
bankAccount: "2345r678908765432",
bankName: "Equity",
createdAt: new Date(),
updatedAt: new Date()
},
{
id:paymentFourId,
userId:userSevenId,
bankPayment: true,
mobilePayment: false,
bankAccount: "2345r678908765432",
bankName: "Equity",
createdAt: new Date(),
updatedAt: new Date()
},
{
id:paymentFiveId,
userId:userFourTeenId,
bankPayment: true,
mobilePayment: false,
bankAccount: "2345r678908765432",
bankName: "Equity",
createdAt: new Date(),
updatedAt: new Date()
},
{
id:paymentSixId,
userId:userFiveTeenId,
bankPayment: true,
mobilePayment: false,
bankAccount: "2345r678908765432",
bankName: "Equity",
createdAt: new Date(),
updatedAt: new Date()
}
], {});
},
async down(queryInterface: QueryInterface) {
await queryInterface.bulkDelete("paymentMethods", null, {});
}
};
90 changes: 90 additions & 0 deletions src/databases/seeders/20240725171531-sellerProfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { QueryInterface } from "sequelize";
import { userFourId, userFiveTeenId, userFourTeenId, userSevenId, userSixId, userFiveId, shopOneId, sellerProfileOneId, sellerProfileSixId, sellerProfileFiveId, shopThreeId, sellerProfileFourId, sellerProfileThreeId, sellerProfileTwoId, shopFourId, shopTwoId, shopFiveId, shopSixId, paymentFiveId, paymentFourId, paymentSixId, paymentThreeId, paymentTwoId } from "../../types/uuid";

const sellerProfileOne = {
id:sellerProfileOneId,
userId: userFourId,
shopsId: shopOneId,
paymentMethodId:paymentFiveId,
businessName:"Paccy Shop 250",
tin:"1234567",
rdbDocument:"https://res.cloudinary.com/du0vvcuiz/image/upload/v1724088050/qm9svaanorpl8wkosaio.pdf",
terms:true,
requestStatus: "Accepted",
createdAt: new Date(),
updatedAt: new Date()
}

const sellerProfileTwo = {
id: sellerProfileTwoId,
userId: userFiveId,
shopsId: shopFiveId,
paymentMethodId:paymentTwoId,
businessName:"Shop 509",
tin:"2345678",
rdbDocument:"https://res.cloudinary.com/du0vvcuiz/image/upload/v1724088050/qm9svaanorpl8wkosaio.pdf",
terms:true,
requestStatus: "Accepted",
createdAt: new Date(),
updatedAt: new Date()
}
const sellerProfileThree = {
id:sellerProfileThreeId,
userId: userSixId,
shopsId: shopFourId,
paymentMethodId:paymentThreeId,
businessName:"electronic Shop 509",
tin:"3456789",
rdbDocument:"https://res.cloudinary.com/du0vvcuiz/image/upload/v1724088050/qm9svaanorpl8wkosaio.pdf",
terms:true,
requestStatus: "Accepted",
createdAt: new Date(),
updatedAt: new Date()
}
const sellerProfileFour = {
id:sellerProfileFourId,
userId: userSevenId,
shopsId: shopTwoId,
paymentMethodId:paymentFourId,
businessName:"Paccy Shop 509",
tin:"4567890",
rdbDocument:"https://res.cloudinary.com/du0vvcuiz/image/upload/v1724088050/qm9svaanorpl8wkosaio.pdf",
terms:true,
requestStatus: "Accepted",
createdAt: new Date(),
updatedAt: new Date()
}
const sellerProfileFive = {
id:sellerProfileFiveId,
userId: userFourTeenId,
shopsId: shopThreeId,
paymentMethodId:paymentFiveId,
businessName:"Shoes Shop 509",
tin:"5678901",
rdbDocument:"https://res.cloudinary.com/du0vvcuiz/image/upload/v1724088050/qm9svaanorpl8wkosaio.pdf",
terms:true,
requestStatus: "Accepted",
createdAt: new Date(),
updatedAt: new Date()
}
const sellerProfileSix = {
id:sellerProfileSixId,
userId: userFiveTeenId,
shopsId: shopSixId,
paymentMethodId:paymentSixId,
businessName:"electronics Shop 509",
tin:"6789012",
rdbDocument:"https://res.cloudinary.com/du0vvcuiz/image/upload/v1724088050/qm9svaanorpl8wkosaio.pdf",
terms:true,
requestStatus: "Accepted",
createdAt: new Date(),
updatedAt: new Date()
}

export const up = async (queryInterface: QueryInterface) => {
await queryInterface.bulkInsert("sellerProfiles", [sellerProfileOne, sellerProfileTwo,sellerProfileThree,sellerProfileFour,sellerProfileFive,sellerProfileSix ]);
};

export const down = async (queryInterface: QueryInterface) => {
await queryInterface.bulkDelete("sellerProfiles", {});
};
Loading

0 comments on commit 4721862

Please sign in to comment.