Skip to content

Commit

Permalink
Merge pull request #35 from atlp-rwanda/fix-testing-eslint-config
Browse files Browse the repository at this point in the history
fixing eslint configuration and testing packages missing
  • Loading branch information
faid-terence authored Apr 28, 2024
2 parents c4904a3 + 422d64f commit ecf4597
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ module.exports = {
"ignoreRestSiblings": true
}
],
'no-undef': 'warn',
'no-undef': 'off',
'semi': ['warn', 'always'],
'no-multi-spaces': 'warn',
'no-trailing-spaces': 'warn',
'space-before-function-paren': ['warn', 'always'],
'func-style': ['warn', 'declaration', { 'allowArrowFunctions': true }],
'camelcase': 'warn',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': ['warn', { accessibility: 'explicit' }],
'@typescript-eslint/explicit-member-accessibility': ['off', { accessibility: 'explicit' }],
'no-unused-vars': 'warn',
'no-extra-semi': 'warn',
},
Expand Down
20 changes: 1 addition & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@types/jest": "^29.5.12",
"@types/jsend": "^1.0.32",
"@types/morgan": "^1.9.9",
"@types/supertest": "^6.0.2",
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
Expand All @@ -60,24 +61,5 @@
"ts-jest": "^29.1.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.7.1"
},
"eslintConfig": {
"root": true,
"env": {
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
}
11 changes: 3 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ const port = process.env.PORT as string;
app.use(express.json());

app.use(cors({ origin: "*" }));

app.use(router);
addDocumentation(app);
app.all('*', (req: Request,res: Response,next) =>{
const error = new CustomError(`Can't find ${req.originalUrl} on the server!`,404);
error.status = 'fail';
next(error);
});

addDocumentation(app);
app.get("/api/v1", (req: Request, res: Response) => {
res.send("Knights Ecommerce API");
});
app.use(router);
app.use(errorHandler);

//morgan
Expand All @@ -33,6 +28,6 @@ app.use(morgan(morganFormat));



app.listen(port, () => {
export const server = app.listen(port, () => {
console.log(`[server]: Server is running at http://localhost:${port}`);
});
4 changes: 4 additions & 0 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Request, Response, Router } from 'express';
import { responseSuccess } from '../utils/response.utils';
const router = Router();
router.get("/", (req: Request, res: Response) => {
res.send("Knights Ecommerce API");
});
router.get('/api/v1/status', (req: Request, res: Response) => {
return responseSuccess(res, 202, 'This is a testing route that returns: 201');
});

// All routes should be imported here and get export after specifying first route
// example router.use("/stock". stockRoutes) =>:: First import stockRoutes and use it here, This shows how the route export will be handled

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
"types": ["node"] /* Specify type package names to be included without being referenced in a source file. */,
"types": ["node", "jest"] /* Specify type package names to be included without being referenced in a source file. */,
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
Expand Down

0 comments on commit ecf4597

Please sign in to comment.