Skip to content

Commit 374cbc1

Browse files
authored
Merge pull request #3 from frckbrice/chore/testings
Chore/testings fully functional
2 parents 14e9aae + 651acb0 commit 374cbc1

28 files changed

Lines changed: 3237 additions & 622 deletions

README.md

Lines changed: 330 additions & 69 deletions
Large diffs are not rendered by default.

TROUBLESHOOTING.md

Lines changed: 575 additions & 0 deletions
Large diffs are not rendered by default.

app.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const doc: any = {
9191
const swaggerSpec = swaggerJsDoc(doc);
9292
// app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerJsDoc(doc)));
9393

94-
const imagesDir = path.join(__dirname, "/src/public/images");
94+
const imagesDir = path.join(__dirname, "../public/assets/images");
9595

9696
// Ensure the directory exists at app start
9797
if (!fs.existsSync(imagesDir)) {
@@ -105,7 +105,9 @@ app.use(helmet());
105105

106106
app.use(bodyParser.json());
107107
app.use(cors());
108-
app.use("/public/images", express.static("public/images"));
108+
app.use("/public", express.static("public"));
109+
app.use("/public/assets", express.static("public/assets"));
110+
app.use("/public/assets/images", express.static("public/assets/images"));
109111

110112
// Routes setup
111113
app.use("/api/v1", appRouter);
@@ -130,15 +132,24 @@ app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
130132
* properties:
131133
* message:
132134
* type: string
133-
* example: "Hello World!! Farming products_2"
135+
* example: "Hello World!! Farming products"
134136
*/
135137
app.get("/", (req: Request, res: Response) => {
136-
res.send("Hello World!! Farming products_2");
138+
res.sendFile(path.join(__dirname, "../public/index.html"));
137139
});
138140

139-
// 404 handler
141+
// 404 handler - serve custom 404 page for HTML requests, JSON for API requests
140142
app.use((req: Request, res: Response, next: NextFunction) => {
141-
next(new AppError(`Not Found - ${req.originalUrl}`, 404));
143+
// Check if the request is for an API endpoint or expects JSON
144+
const isAPIRequest = req.path.startsWith('/api/v1') || req.get('Accept')?.includes('application/json');
145+
146+
if (isAPIRequest) {
147+
// For API requests, return JSON error
148+
next(new AppError(`Not Found - ${req.originalUrl}`, 404));
149+
} else {
150+
// For web requests, serve the custom 404 page
151+
res.status(404).sendFile(path.join(__dirname, "../public/404.html"));
152+
}
142153
});
143154

144155
// Error handling middleware - must be last

docker-compose.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
POSTGRES_PASSWORD: ${DB_PASSWORD:-postgres}
88
POSTGRES_DB: ${DB_HOSTNAME:-farming_products}
99
ports:
10-
- "5432:5432"
10+
- "5433:5432"
1111
volumes:
1212
- db_data:/var/lib/postgresql/data
1313

@@ -16,7 +16,7 @@ services:
1616
depends_on:
1717
- db
1818
environment:
19-
NODE_ENV: production
19+
NODE_ENV: development
2020
DB_HOST: db
2121
DB_PORT: 5432
2222
DB_USER: ${DB_USER:-postgres}
@@ -39,10 +39,15 @@ services:
3939
TWILIO_AUTH_TOKEN: ${TWILIO_AUTH_TOKEN}
4040
TWILIO_PHONE: ${TWILIO_PHONE}
4141
BREVO_API_KEY: ${BREVO_API_KEY}
42+
# Adwa Payment Configuration
43+
ADWA_MERCHANT_KEY: ${ADWA_MERCHANT_KEY}
44+
ADWA_APPLICATION_KEY: ${ADWA_APPLICATION_KEY}
45+
ADWA_SUBSCRIPTION_KEY: ${ADWA_SUBSCRIPTION_KEY}
46+
ADWA_BASE_URL: ${ADWA_BASE_URL}
4247
ports:
4348
- "3000:3000"
4449
restart: always
45-
command: sh -c "yarn install && yarn build && npx sequelize-cli db:migrate && node dist/app.js"
50+
command: node dist/app.js
4651

4752
volumes:
4853
db_data:

eslint.config.mjs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
import js from "@eslint/js";
22
import globals from "globals";
3-
import tseslint from "typescript-eslint";
3+
import tseslint from "@typescript-eslint/eslint-plugin";
4+
import tsparser from "@typescript-eslint/parser";
45
import { defineConfig } from "eslint/config";
56

6-
77
export default defineConfig([
8-
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], plugins: { js }, extends: ["js/recommended"] },
9-
{ files: ["**/*.{js,mjs,cjs,ts,mts,cts}"], languageOptions: { globals: globals.browser } },
10-
tseslint.configs.recommended,
8+
{
9+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
10+
plugins: { js },
11+
extends: ["js/recommended"],
12+
languageOptions: {
13+
globals: {
14+
...globals.node,
15+
...globals.browser
16+
}
17+
}
18+
},
19+
{
20+
files: ["**/*.{ts,mts,cts}"],
21+
languageOptions: {
22+
parser: tsparser,
23+
parserOptions: {
24+
ecmaVersion: "latest",
25+
sourceType: "module",
26+
},
27+
globals: {
28+
...globals.node,
29+
...globals.browser
30+
}
31+
},
32+
plugins: {
33+
"@typescript-eslint": tseslint,
34+
},
35+
rules: {
36+
...tseslint.configs.recommended.rules,
37+
"@typescript-eslint/no-unused-vars": "error",
38+
},
39+
},
1140
]);

package.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"dependencies": {
2323
"@faker-js/faker": "^9.5.1",
2424
"@sequelize/postgres": "^7.0.0-alpha.43",
25-
"@types/swagger-ui": "^3.52.4",
2625
"axios": "^1.7.2",
2726
"bcryptjs": "^2.4.3",
2827
"body-parser": "^1.20.2",
@@ -31,23 +30,17 @@
3130
"dotenv": "^16.4.5",
3231
"express": "4",
3332
"express-rate-limit": "^7.2.0",
34-
"fs": "^0.0.1-security",
3533
"google-auth-library": "^9.14.0",
3634
"helmet": "^7.0.0",
3735
"jsonwebtoken": "^9.0.2",
3836
"multer": "^1.4.5-lts.1",
39-
"mysql2": "^3.11.5",
4037
"nodemailer": "^6.9.13",
41-
"path": "^0.12.7",
4238
"pg": "^8.13.1",
4339
"pg-hstore": "^2.3.4",
4440
"reflect-metadata": "^0.2.2",
4541
"sequelize": "^6.37.5",
46-
"sequelize-cli": "^6.6.2",
4742
"sequelize-typescript": "^2.1.6",
48-
"sib-api-v3-sdk": "^8.5.0",
4943
"socket.io": "^4.7.5",
50-
"swagger-autogen": "^2.23.7",
5144
"swagger-jsdoc": "^6.2.8",
5245
"swagger-ui-express": "^5.0.0",
5346
"tslib": "^2.8.1",
@@ -62,29 +55,24 @@
6255
"@types/body-parser": "^1.19.5",
6356
"@types/cors": "^2.8.13",
6457
"@types/express": "^4.17.21",
65-
"@types/fs-extra": "^9.0.13",
6658
"@types/helmet": "^4.0.0",
6759
"@types/jsonwebtoken": "^9.0.2",
6860
"@types/multer": "^1.4.7",
6961
"@types/node": "^22.10.2",
70-
"@types/node-fetch": "^2.6.12",
7162
"@types/nodemailer": "^6.4.7",
7263
"@types/sequelize": "^4.28.20",
7364
"@types/supertest": "^6.0.3",
7465
"@types/swagger-jsdoc": "^6.0.3",
7566
"@types/swagger-ui-express": "^4.1.7",
7667
"@types/uuid": "^9.0.2",
77-
"@types/validator": "^13.12.2",
7868
"@typescript-eslint/eslint-plugin": "^8.38.0",
7969
"@typescript-eslint/parser": "^8.38.0",
8070
"@vitest/coverage-v8": "^3.2.4",
8171
"eslint": "^9.31.0",
82-
"globals": "^16.3.0",
8372
"nodemon": "^3.1.0",
8473
"prettier": "^3.6.2",
8574
"supertest": "^7.1.4",
8675
"ts-node": "^10.9.2",
87-
"typescript-eslint": "^8.38.0",
8876
"vitest": "^3.2.4"
8977
}
9078
}

0 commit comments

Comments
 (0)