-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Intialize NodeJS and TS bolierplate
- Loading branch information
0 parents
commit 7a359b3
Showing
27 changed files
with
3,320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DB_URI= db uri | ||
PORT= port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module.exports = { | ||
env: { | ||
es2021: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
'eslint:recommended', | ||
'airbnb', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint', 'prettier'], | ||
rules: { | ||
'import/no-unresolved': 0, | ||
'import/prefer-default-export': 0, | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
endOfLine: 'auto', | ||
}, | ||
], | ||
'prefer-const': [ | ||
'error', | ||
{ | ||
destructuring: 'any', | ||
ignoreReadBeforeAssign: false, | ||
}, | ||
], | ||
'linebreak-style': 0, | ||
'no-unused-vars': 1, | ||
'no-useless-escape': 0, | ||
radix: ['error', 'as-needed'], | ||
'no-param-reassign': 0, | ||
camelcase: 0, | ||
'import/extensions': 0, | ||
'no-use-before-define': 0, | ||
'consistent-return': 0, | ||
|
||
// FIx me | ||
'no-console': 0, | ||
'@typescript-eslint/no-explicit-any': 0, | ||
'@typescript-eslint/explicit-module-boundary-types': 0, | ||
'no-underscore-dangle': 0, | ||
'import/no-extraneous-dependencies': 0, | ||
'prefer-destructuring': 0, | ||
'no-unused-expressions': 0, | ||
'no-return-assign': 0, | ||
'no-await-in-loop': 0, | ||
'no-return-await': 0, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Expected Behavior | ||
|
||
Please describe the behavior you are expecting | ||
|
||
# Current Behavior | ||
|
||
What is the current behavior? | ||
|
||
# Failure Information | ||
|
||
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template. | ||
|
||
# URL to test the bug | ||
|
||
URL to test the bug | ||
|
||
## Steps to Reproduce | ||
|
||
Please provide detailed steps for reproducing the issue. | ||
|
||
1. step 1 | ||
2. step 2 | ||
3. you get it... | ||
|
||
## Screenshots | ||
|
||
Please include screenshots of the bug | ||
|
||
## Error Logs | ||
|
||
Please include any relevant log snippets or files here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
# Expected Behavior | ||
|
||
Please describe the behavior you are expecting | ||
|
||
# Current Behavior | ||
|
||
What is the current behavior? | ||
|
||
# Failure Information | ||
|
||
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template. | ||
|
||
# URL to test the bug | ||
|
||
URL to test the bug | ||
|
||
## Steps to Reproduce | ||
|
||
Please provide detailed steps for reproducing the issue. | ||
|
||
1. step 1 | ||
2. step 2 | ||
3. you get it... | ||
|
||
## Screenshots | ||
|
||
Please include screenshots of the bug | ||
|
||
## Error Logs | ||
|
||
Please include any relevant log snippets or files here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
name: Custom issue template | ||
about: Describe this issue template's purpose here. | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
# Is your feature request related to a problem? Please describe | ||
|
||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
# Describe the solution you'd like | ||
|
||
A clear and concise description of what you want to happen. | ||
|
||
# Describe alternatives you've considered | ||
|
||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
# Revelant Screenshots | ||
|
||
Add any other context or screenshots about the feature request here. | ||
|
||
# Additional context | ||
|
||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Description | ||
|
||
Please include a summary of the change. | ||
|
||
Fixes # (issue) | ||
|
||
## Type of change | ||
|
||
Please delete options that are not relevant. | ||
|
||
- [ ] Bug fix | ||
- [ ] New feature | ||
- [ ] Documentation | ||
|
||
# Checklist: | ||
|
||
- [ ] My code follows the style guidelines of this project | ||
- [ ] I have performed a self-review of my own code | ||
- [ ] My changes generate no new warnings | ||
- [ ] I have formatted the changes | ||
- [ ] I have checked my changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.vscode | ||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
build | ||
docs | ||
uploads | ||
.env.test | ||
|
||
|
||
# misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
|
||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
build | ||
docs | ||
uploads | ||
.env.test | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"endOfLine": "crlf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Router, Request, Response } from 'express'; | ||
|
||
const healthController = async (req: Request, res: Response) => { | ||
console.log('Hi'); | ||
res.status(200).json({ status: true }); | ||
}; | ||
|
||
export const healthRouter = (): Router => { | ||
const router: Router = Router(); | ||
router.get('/', healthController); | ||
|
||
return router; | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const TOO_MANY_REQUESTS_ERROR = { | ||
error: 'Too Many Request, Please try after some time!', | ||
}; | ||
|
||
export const SERVER_ERROR = { code: 500, message: 'Internal Server error' }; | ||
|
||
export const UNAUTHORIZED_ERROR = { | ||
code: 401, | ||
message: "Stop! Unautorized access, You can't proceed further", | ||
}; | ||
|
||
export const BAD_REQUEST = { | ||
code: 400, | ||
message: 'Uh,oh! The request is badly made', | ||
}; | ||
|
||
export const INVALID_RECAPTCHA_CODE = { | ||
code: 401, | ||
message: 'Invalid recaptcha code', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './errors'; | ||
export * from './response'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
interface Response { | ||
status: string; | ||
statusCode: number; | ||
message: string; | ||
} | ||
|
||
export const generateResponse = ( | ||
statusCode: number, | ||
message: string | ||
): Response => { | ||
return { | ||
status: 'success', | ||
statusCode, | ||
message, | ||
}; | ||
}; | ||
|
||
export const generateErrorMessage = (customError: any): Response => { | ||
const errorResponse = { | ||
status: 'error', | ||
statusCode: customError.code, | ||
message: customError.message, | ||
}; | ||
return errorResponse; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { MongoClient } from 'mongodb'; | ||
|
||
let dbClient: MongoClient; | ||
|
||
export async function initDbClient(): Promise<MongoClient> { | ||
try { | ||
dbClient = await MongoClient.connect(process.env.DB_URI || '', { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
ignoreUndefined: true, | ||
}); | ||
console.log('Connected to Database'); | ||
return dbClient; | ||
} catch (error) { | ||
console.log('Cannot connect to Database', error); | ||
} | ||
} | ||
|
||
export async function getDbClient(): Promise<MongoClient> { | ||
if (!dbClient) { | ||
await initDbClient(); | ||
} | ||
return dbClient; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './database'; |
Oops, something went wrong.