Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…injas-bn into ft-login-user-187584915
  • Loading branch information
ProgrammerDATCH committed May 29, 2024
2 parents 213e89c + 80e32f4 commit 1cc6348
Show file tree
Hide file tree
Showing 20 changed files with 710 additions and 274 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- image: cimg/node:18.17.0
steps:
- setup_remote_docker:
version: 20.10.7
version: docker24
- checkout
- run:
name: update-npm
Expand Down
28 changes: 23 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
PORT=
NODE_ENV=
NODE_EN=
DOCKER_DATABASE_HOST_AUTH_METHOD=
DOCKER_DATABASE_NAME=
DOCKER_DATABASE_PASSWORD=
JWT_SECRET=
NODE_ENV=

SMTP_HOST_PORT=
MP=
SMTP_HOST=
MAIL_ID=

CLOUD_NAME=
API_KEY=
API_SECRET=

SERVER_URL_DEV=
SERVER_URL_PRO=

DATABASE_URL_DEV=
DATABASE_URL_TEST=
DATABASE_URL_PRO=
DB_HOST_TYPE=



DB_HOST_TYPE=
DOCKER_DATABASE_USER=
DOCKER_DATABASE_HOST_AUTH_METHOD=
DOCKER_DATABASE_NAME=
DOCKER_DATABASE_PASSWORD=
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
push:
branches:
- develop

env:
PORT: ${{ secrets.PORT }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
Expand All @@ -17,6 +16,12 @@ env:
API_SECRET: ${{ secrets.API_SECRET }}
CLOUD_NAME: ${{ secrets.CLOUD_NAME }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
SERVER_URL_PRO : ${{ secrets.SERVER_URL_PRO }}
SMTP_HOST_PORT: ${{ secrets.SMTP_HOST_PORT }}
MP : ${{ secrets.MP }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
MAIL_ID: ${{ secrets.MAIL_ID }}
DB_HOST_TYPE: ${{ secrets.DB_HOST_TYPE }}

jobs:
build:
Expand Down Expand Up @@ -47,6 +52,7 @@ jobs:

- run: npm run coverage --if-present


- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
Expand Down
7 changes: 7 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"check-coverage": true,
"lines": 80,
"functions": 80,
"branches": 80,
"statements": 80
}
65 changes: 16 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Team Ninjas Backend
# TEAM NINJAS BACKEND

This is the backend for E-Commerce-Ninjas, written in Node.js with TypeScript.

Expand All @@ -23,22 +23,28 @@ This is the backend for E-Commerce-Ninjas, written in Node.js with TypeScript.
[https://github.com/atlp-rwanda/e-commerce-ninjas-bn](https://github.com/atlp-rwanda/e-commerce-ninjas-bn)


## Completed Features
## COMPLETED FEATURES

- Welcome Endpoint
- Register Endpoint
- Verification Email Endpoint
- Resend verification Endpoint
- Login Endpoint

## TABLE OF API ENDPOINTS SPECIFICATION AND DESCRIPTION


| No | VERBS | ENDPOINTS | STATUS | ACCESS | DESCRIPTION |
|----|-------|-------------------|--------|--------|-------------------- |
| 1 | GET | / | 200 OK | public | Show welcome message|
| 2 | POST | /api/auth/register| 200 OK | public | create user account |
| No | VERBS | ENDPOINTS | STATUS | ACCESS | DESCRIPTION |
|----|-------|------------------------------|-------------|--------|---------------------------|
| 1 | GET | / | 200 OK | public | Show welcome message |
| 2 | POST | /api/auth/register | 201 CREATED | public | create user account |
| 3 | GET | /api/auth/verify-email/:token| 200 OK | public | Verifying email |
| 4 | POST | /api/auth/send-verify-email | 200 OK | public | Resend verification email |
| 4 | POST | /api/auth/login | 200 OK | public | Login with Email and Password |



## Installation
## INSTALLATION

1. Clone the repository:

Expand All @@ -59,7 +65,7 @@ This is the backend for E-Commerce-Ninjas, written in Node.js with TypeScript.
npm run dev
```

## Folder Structure
## FOLDER STRUCTURE

- `.env`: Secure environment variables.
- `src/`: Source code directory.
Expand All @@ -80,7 +86,7 @@ This is the backend for E-Commerce-Ninjas, written in Node.js with TypeScript.
- `services/`: Service functions like sendEmails.
- `index.ts`: Startup file for all requests.

## Initialize Sequelize CLI
## INITILIAZE SEQUELIZE CLI

1. Initialize Sequelize CLI:
```sh
Expand Down Expand Up @@ -113,43 +119,4 @@ This is the backend for E-Commerce-Ninjas, written in Node.js with TypeScript.
9. Delete the Migration:
```sh
npm run deleteAllTables
```



## Initialize Sequelize CLI

1. Initialize Sequelize CLI:
```sh
npx sequelize-cli init
```
2. Generate Seeder:
```sh
npx sequelize-cli seed:generate --name name-of-your-seeder
```
3. Generate Migrations:
```sh
npx sequelize-cli migration:generate --name name-of-your-migration
```
4. Define Migration:
Edit the generated migration file to include the tables you want to create.
5. Define Seeder Data:
Edit the generated seeder file to include the data you want to insert.
6. Run the Seeder:
```sh
npm run createAllSeeders
```
7. Run the Migration:
```sh
npm run createAllTables
```
8. Delete the Seeder:
```sh
npm run deleteAllSeeders
```
9. Delete the Migration:
```sh
npm run deleteAllTables
```


```
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
},
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript",
"check-coverage": true,
"all": true,
"include": [
"src/**/!(*.test.*).[tj]s?(x)"
],
Expand All @@ -46,7 +44,8 @@
"text-summary"
],
"report-dir": "coverage",
"lines": 40
"check-coverage": true,
"all": true
},
"keywords": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion src/databases/migrations/20240520180022-create-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
defaultValue: false
},
status: {
type: new DataTypes.BOOLEAN,
type: new DataTypes.STRING(128),
allowNull: false,
defaultValue: true
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { QueryInterface, DataTypes } from "sequelize";
export default {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("tokens", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
userId: {
type: new DataTypes.INTEGER,
allowNull: false
},
device: {
type: new DataTypes.STRING(280),
allowNull: true
},
accessToken: {
type: new DataTypes.STRING(280),
allowNull: true
},
verifyToken: {
type: new DataTypes.STRING(280),
allowNull: true
},
createdAt: {
field: "createdAt",
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
updatedAt: {
field: "updatedAt",
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
}
});
},

down: async (queryInterface: QueryInterface) => {
await queryInterface.dropTable("tokens");
}
};
import { QueryInterface, DataTypes } from "sequelize";
export default {
up: async (queryInterface: QueryInterface) => {
await queryInterface.createTable("sessions", {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
userId: {
type: new DataTypes.INTEGER,
allowNull: false
},
device: {
type: new DataTypes.STRING(280),
allowNull: true
},
token: {
type: new DataTypes.STRING(280),
allowNull: true
},
otp: {
type: new DataTypes.STRING(280),
allowNull: true
},
createdAt: {
field: "createdAt",
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
updatedAt: {
field: "updatedAt",
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
}
});
},

down: async (queryInterface: QueryInterface) => {
await queryInterface.dropTable("sessions");
}
};
Loading

0 comments on commit 1cc6348

Please sign in to comment.